sanjeevbinf has asked for the wisdom of the Perl Monks concerning the following question:
my query must be a silly, but I have been finding hard to undestand json. Apart from knowing it is a key value pair, I cannot undertand much. How to initiate it. How to loop over it. How to print it without using print Dumper. Is it a hash or is it reference?
example:Above, I want 2 values in trans1 key.my $son = '{ }'; my $r=decode_json($son);#cannot understand why I need to do $r->{"trans2"}[0]="90"; $r->{"trans2"}[1]="20"; print "\n\n"; #print Dumper \$r; # without dumper, how can I iterate using for loop? print $r->{"trans2"}[0],"\n"; #hard coded print $r->{"trans2"}[1],"\n"; #hard coded
How do I iterate over keys in json object?
Sorry, I have posted this in wrong forum. Admins, pleae move this thread to respective forum
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: understanding json in perl
by atcroft (Abbot) on Apr 25, 2014 at 04:43 UTC | |
by sanjeevbinf (Initiate) on Apr 27, 2014 at 05:19 UTC | |
|
Re: understanding json in perl
by NetWallah (Canon) on Apr 25, 2014 at 05:35 UTC | |
|
Re: understanding json in perl
by locked_user sundialsvc4 (Abbot) on Apr 27, 2014 at 00:29 UTC |