omegaweaponZ has asked for the wisdom of the Perl Monks concerning the following question:
(etc...) I currently already can store subject1's value as well as the array of subject2 and grab its subject3 value.{ "1": {"subject1": "value", "subject2": [{"subject3": "value", "subject +4": "value"}], "subject5": "value", "subject6": value, "subject7": "v +alue"}, "2": {"subject1": "value", "subject2": [{"subject3": "value", "subject +4": "value"}], "subject5": "value", "subject6": value, "subject7": "v +alue"}, "3": {"subject1": "value", "subject2": [{"subject3": "value", "subject +4": "value"}], "subject5": "value", "subject6": value, "subject7": "v +alue"} }
So this is all nice, but I need to store the first value of each {} sequence which is listed here as 1{}, 2{}, 3, etc as well in a variable, and then loop the whole thing in one giant while or foreach loop. I can't seem to grab every value, however, of $data->{$_}. Anyone have a good idea?my $jsonfeed = (above json format!) my $json = new JSON; my $data = $json->decode($jsonfeed); my $value = "$data->{1}->{subject1}"; foreach my $array(@{$data->{1}->{subject2}}){ my %hash = (); $hash{subject3} = $array->{subject3}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: JSON Structure Question
by stephen (Priest) on May 22, 2013 at 22:00 UTC | |
|
Re: JSON Structure Question
by roboticus (Chancellor) on May 23, 2013 at 13:10 UTC | |
by omegaweaponZ (Beadle) on May 23, 2013 at 15:36 UTC | |
by omegaweaponZ (Beadle) on May 23, 2013 at 18:58 UTC | |
|
Re: JSON Structure Question
by hdb (Monsignor) on May 23, 2013 at 14:07 UTC | |
by omegaweaponZ (Beadle) on May 23, 2013 at 16:00 UTC | |
|
Re: JSON Structure Question
by Anonymous Monk on May 23, 2013 at 02:25 UTC |