[dancer-users] serialize

Zahir Lalani ZahirLalani at oliver-marketing.com
Thu Mar 19 20:45:54 GMT 2015


Yeah I read that bit after sending the mail ☹

thx

From: dancer-users [mailto:dancer-users-bounces at dancer.pm] On Behalf Of Hao Wu
Sent: 19 March 2015 19:18
To: Perl Dancer users mailing list
Subject: Re: [dancer-users] serialize

Hi,

read the doc here, please.

https://metacpan.org/pod/JSON#allow_blessed

you need implement TO_JSON method to your object.


On Thu, Mar 19, 2015 at 10:33 AM, Zahir Lalani <ZahirLalani at oliver-marketing.com<mailto:ZahirLalani at oliver-marketing.com>> wrote:
Hi

In order work around the routing issue I posted earlier, I am trying to serialise the output but I get nulls.

The dump of the output structure is:
$VAR1 = [
          bless( {
                   'org_name' => 'Fashion',
                   'id' => 3
                 }, 'org_list_dom' ),
          bless( {
                   'org_name' => 'Market',
                   'id' => 4
                 }, 'org_list_dom' ),
          bless( {
                   'org_name' => 'Property',
                   'id' => 5
                 }, 'org_list_dom' ),
          bless( {
                   'org_name' => 'Misc',
                   'id' => 6
                 }, 'org_list_dom' )

Passing this ($res)  into serialize:

               my $json = to_json( $res, { allow_blessed => 1, convert_blessed => 1 } );

gives

[null,null,null,null]

Any clues as to what I may be doing wrong?

Z

_______________________________________________
dancer-users mailing list
dancer-users at dancer.pm<mailto:dancer-users at dancer.pm>
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150319/ce767853/attachment-0001.html>


More information about the dancer-users mailing list