> The documentation isn't clear on how, but this implies some combination of > these flags (probably setting both to true) should do the "encoding the > reference as if it weren't blessed" thing.
No, allow_blessed(1) means it will not die, it will instead print out the totally useless string 'null'. This is technically allowing a blessed scalar. However, convert_blessed, is a total misnomer as nothing is /converted/. All that happens is the method TO_JSON is called. ecarr...@rda:~$ perl -MJSON::XS -E'my $o = bless { foo=>'bar' }; say JSON::XS->new->encode( $o );' encountered object 'main=HASH(0x7b8df0)', but neither allow_blessed nor convert_blessed settings are enabled at -e line 1. ecarr...@rda:~$ perl -MJSON::XS -E'my $o = bless { foo=>'bar' }; say JSON::XS->new->allow_blessed(1)->encode( $o );' null ecarr...@rda:~$ perl -MJSON::XS -E'my $o = bless { foo=>'bar' }; say JSON::XS->new->allow_blessed(1)->convert_blessed(1)->encode( $o );' null In this example the object is blessed in the default package main, where TO_JSON is called. ecarr...@rda:~$ perl -MJSON::XS -E'my $o = bless { foo=>'bar' }; sub TO_JSON { "hi" }; say JSON::XS->new->allow_blessed(1)->convert_blessed(1)->encode( $o );' "hi" But yes, ideally /convert_blessed/ would do what I want rather than just call a sub that expects me to do it. My handy old XXX.pm does this right: ecarr...@rda:~$ perl -E'my $o = bless { foo=>'bar' }; use XXX; XXX $o' --- !!perl/hash:main foo: bar ... at -e line 1 -- Evan Carroll - m...@evancarroll.com System Lord of the Internets web: http://www.evancarroll.com ph: 281.901.0011 _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/