Traverse nested hash and construct a new one

Joined
Jun 14, 2017
Messages
1
Reaction score
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
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,560
Members
45,035
Latest member
HoTaKeDai

Latest Threads

Top