Yeah I read that bit after sending the mail L

 

thx

 

From: dancer-users [mailto:dancer-users-bounces@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@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@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users