in reply to How to output proper JSON
The output is correct. $customers{'cust'} contains a (reference to a) hash with the keys "id" and "name". The encode_json output shows precisely that.
So if you want your result to be a map containing an array containing a map, you'd have to alter your original data structure to represent that. Instead of having $customers{'cust'} contain a hashref, have it contain an arrayref instead.
# I didn't test the code, but I suspect this should give you what you +want. $customers{'cust'} = [ { id => $id, name => $name, } ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to output proper JSON
by Anonymous Monk on Dec 14, 2011 at 23:43 UTC |