divyaP has asked for the wisdom of the Perl Monks concerning the following question:
Hi, i am fetching results from mysql DB and want to get a proper json output. with JSON:PP encode_json function i get the below output
use JSON::PP; my $json = JSON::PP->new; my $json_output=encode_json( { JSON1=> \@my_A } ); print $json_output;
output is
{"JSON1":["{\"name\":\"Name 1\",\"myArray\":[1,2,3]}","{\"name\":\"Nam +e 2\",\"myArray\":[4,0,0]}","{\"name\":\"Name 3\",\"myArray\":[5,0,6] +}"]}
but my JS script think the below format is the correct one
{"JSON1":[{"name":"Name 1","myArray":[1,2,3]},{"name":"Name 2","myArra +y":[4,0,0]},{"name":"Name 3","myArray":[5,0,6]}]}
without the additional \ and ". Any help please?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl-json format
by moritz (Cardinal) on Apr 18, 2012 at 06:23 UTC | |
by divyaP (Initiate) on Apr 18, 2012 at 06:53 UTC | |
|
Re: perl-json format
by zwon (Abbot) on Apr 18, 2012 at 06:21 UTC | |
|
Re: perl-json format (data)
by tye (Sage) on Apr 18, 2012 at 06:13 UTC |