Hi all,
I am trying to build JSON such as this with Perl:
[{"name":"picture1.jpg","size":902604,"url":"\/\/example.org\/files\/picture1.jpg","thumbnail_url":"\/\/example.org\/thumbnails\/picture1.jpg","delete_url":"\/\/example.org\/upload-handler?file=picture1.jpg","delete_type":"DELETE"},{"name":"picture2.jpg","size":841946,"url":"\/\/example.org\/files\/picture2.jpg","thumbnail_url":"\/\/example.org\/thumbnails\/picture2.jpg","delete_url":"\/\/example.org\/upload-handler?file=picture2.jpg","delete_type":"DELETE"}]Essentially it is JSON array of JSON objects. However, I am not finding any good tutorials online. Does anyone have any suggestions? Currently I am using the JSON::XS module to decode, but I'm open to anything as long as it works.
Currently I have this code:
my %hash = {}; $hash{'lool'} = "WEEEE"; $hash{'YAY'} = "WEEEE"; my $json = JSON->new->allow_nonref; my $json_text = $json->encode(\%hash);
Only problem is that it creates this:
{"lool":"WEEEE","YAY":"WEEEE","HASH(0x8b8410)":null}Which also include the hash reference itself in it. Any help would be appreciated!
Many Thanks,
srchulo
In reply to Build JSON With Perl by srchulo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |