etc.... (there is a lot more, ignore malformed JSON!) So instead of something that has an all encompassing array reference such as{ "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"},
Which would be easy where I can identify each subject's value by a format similar to the one below, it is just separated essentially by unique numbers line by line from {} which are not detecting the array. My older code had said something along the lines of:DATA [ "1": {"subject1": "value"}, "2": {"subject1": "value"} ]
Doing this produces "Not an Array Reference". If I was to use "subject2" as oppsed to 1 from $json-> it does not error out, yet does not show subject 3, subject 4, etc's value.my $jsonoutput = "Above raw JSON format..."; my $json = new JSON; my $jsontext = $json->allow_nonref->utf8->relaxed->escape_slash->l +oose->allow_singlequote->allow_barekey->decode("$jsonoutput"); foreach my $stuff(@{$json->{1}}){ my %hash = (); $hash{subject1} = $stuff->{subject1}; }
In reply to Extract JSON data by omegaweaponZ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |