[dancer-users] ajax plugin, serialize a 1D perl array to JSON

Anand Meher kvmsanand at gmail.com
Sun Jul 7 00:28:48 BST 2013

Dear dancer experts,
                               I have a 1D Perl array which I would like to
encode using JSON and send it as a response to an ajax request.

I have implemented the following steps so far in my dancer app:

*use Dancer::Plugin::Ajax;*
*set serializer => 'JSON';*
*ajax '/getarray' => sub {*
*    my @sendArray;*
*      ...........  *
*   {*
*       @sendArray;  # this is the array I intend to send to the client
Java Script*
*   }*
*  *

 The sendArray is not a (key, value) pair based structure, but a simple 1D
 Can anyone let me know if * "@sendArray"* statement at the end of  ajax
routine above will correctly encode to JSON?

Also is there any way to print (to console) the final encoded JSON object
from the ajax routine at the server end?

thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20130707/52d24c20/attachment.htm>

More information about the dancer-users mailing list