makamaka / JSON

perl implementation of JSON encoder/decoder
42 stars 40 forks source link

neither allow_blessed nor convert_blessed settings are enabled #15

Closed aduitsis closed 5 years ago

aduitsis commented 11 years ago

I have a class named FactSet which contains an array of objects of class Fact. I tried to implement a method like this for FactSet:

sub TO_JSON {
         JSON->new->utf8->allow_blessed->convert_blessed->encode( $_[0]->facts );
 }

The items inside $_[0]->facts are blessed objects of class Fact and this class implements a TO_JSON method. However, when I try to call $fact_set->TO_JSON I get

encountered object 'SNMP::Class::Fact=HASH(0x803b9c7b0)', but neither allow_blessed nor convert_blessed settings are enabled at ...

Is this normal? Should it not descend into the array and convert each object by using its TO_JSON method ?

charsbar commented 8 years ago

I couldn't reproduce this issue. Could you tell me if this still happens to you with the latest versions of JSON/JSON::PP/JSON::XS modules? (please make sure you load the right version of your module, too)

charsbar commented 5 years ago

Closed for now.