[dancer-users] ajax plugin, serialize a 1D perl array to JSON
davidp at preshweb.co.uk
Sun Jul 7 11:38:29 BST 2013
On Sat, 6 Jul 2013 17:59:21 -0700
Rik Brown <rik at rikbrown.co.uk> wrote:
> Of course you could also do:
> results => \@sendArray
> if you want your output to be a hash at the top level.
> Hope this helps!
Rik's answer above is the course of action I'd typically recommend
- because even if you just want the array for now, in future you may
well decide you want to provide other information from that call, too
(perhaps be able to return an error message as a key named 'error', or
return the number of results found as a key named 'count', or return
the average of all the values... etc) - so returning a hashref as Rik
illustrates helps with future-proofing, as you could easily add more
information to the response without breaking existing code.
David Precious ("bigpresh") <davidp at preshweb.co.uk>
More information about the dancer-users