Traverse nested hash and construct a new one

Discussion in 'Ruby' started by logstash, Jun 14, 2017.

  1. logstash

    logstash

    Joined:
    Jun 14, 2017
    Messages:
    1
    Likes Received:
    0
    Hi
    Forum members
    I am new to Ruby and need to construct arrays from the below event hash. By traversing all the event hash at the same time, i have to generate new array like -

    Pname[0], Identity_No[0], Install_State[0],...............
    Pname[1], Identity_No[1], Install_State[1],...............
    Pname[2], Identity_No[2], Install_State[2],...............

    event =
    {
    "Pname" => [
    [ 0] "Windows Genuine Advantage Validation Tool (KB892130)",
    [ 1] "Intel(R) PRO Network Connections 11.2.0.69",
    [ 2] "AddressBook",
    ..................
    ],
    "Identity_No" => [
    [ 0] "null",
    [ 1] "{2222B364-0854-4265-B32E-A142DB9DC7BB}",
    [ 2] "null",
    ..................
    ],
    "Install_State" => [
    [ 0] "5",
    [ 1] "5",
    [ 2] "5",
    ..................
    ],
    "Install_Date2" => [
    [ 0] "null",
    [ 1] "01-19-2010",
    [ 2] "null",
    ..................
    ],
    "version" => [
    [ 0] "1.7.0069.2",
    [ 1] "null",
    [ 2] "null",
    ...................
    ],
    "Caption" => [
    [ 0] "Windows Genuine Advantage Validation Tool (KB892130)",
    [ 1] "Intel(R) PRO Network Connections 11.2.0.69",
    [ 2] "AddressBook",
    ..................
    ],
    "tags" => [
    [0] "multi_tagged"
    ],
    "path" => "/home/xmldata/in.xml",
    "@timestamp" => 2017-06-13T09:48:52.206Z,
    "date_time" => "06-08-2017 19:15:02",
    "Install_Date" => [
    [ 0] "null",
    [ 1] "01-19-2010",
    [ 2] "null",
    ..................
    ],
    "vendor" => [
    [ 0] "Microsoft Corporation",
    [ 1] "Intel",
    [ 2] "null",
    ..................
    ],
    "@version" => "1",
    "host" => "ubuntu",
    "cid" => [
    [0] "DEVICE12345"
    ]
    }
    May be it is easy for you.
    Regards
     
    logstash, Jun 14, 2017
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. loveNUNO
    Replies:
    2
    Views:
    1,330
    loveNUNO
    Nov 20, 2003
  2. jakester
    Replies:
    3
    Views:
    2,262
    jakester
    Apr 3, 2007
  3. Mukesh
    Replies:
    4
    Views:
    937
    Paul N
    Mar 26, 2010
  4. rp
    Replies:
    1
    Views:
    1,046
    red floyd
    Nov 10, 2011
  5. Srijayanth Sridhar
    Replies:
    19
    Views:
    1,129
    David A. Black
    Jul 2, 2008
  6. Mmcolli00 Mom
    Replies:
    5
    Views:
    345
    Mmcolli00 Mom
    Jan 12, 2009
  7. Aldric Giacomoni

    Odd : a = Hash.new(Hash.new)

    Aldric Giacomoni, Nov 4, 2009, in forum: Ruby
    Replies:
    12
    Views:
    372
    Aldric Giacomoni
    Nov 5, 2009
  8. Moh

    I need a VHDL code

    Moh, Jun 8, 2016, in forum: VHDL
    Replies:
    0
    Views:
    719
Loading...