--- JSON-XS/XS.pm 2007/06/23 23:49:29 1.43 +++ JSON-XS/XS.pm 2007/06/25 04:21:14 1.46 @@ -87,7 +87,7 @@ use strict; -our $VERSION = '1.3'; +our $VERSION = '1.4'; our @ISA = qw(Exporter); our @EXPORT = qw(to_json from_json objToJson jsonToObj); @@ -318,6 +318,42 @@ JSON::XS->new->allow_nonref->encode ("Hello, World!") => "Hello, World!" +=item $json = $json->allow_blessed ([$enable]) + +If C<$enable> is true (or missing), then the C method will not +barf when it encounters a blessed reference. Instead, the value of the +B option will decide wether C (C +disabled or no C method found) or a representation of the +object (C enabled and C method found) is being +encoded. Has no effect on C. + +If C<$enable> is false (the default), then C will throw an +exception when it encounters a blessed object. + +=item $json = $json->convert_blessed ([$enable]) + +If C<$enable> is true (or missing), then C, upon encountering a +blessed object, will check for the availability of the C method +on the object's class. If found, it will be called in scalar context +and the resulting scalar will be encoded instead of the object. If no +C method is found, the value of C will decide what +to do. + +The C method may safely call die if it wants. If C +returns other blessed objects, those will be handled in the same +way. C must take care of not causing an endless recursion cycle +(== crash) in this case. The name of C was chosen because other +methods called by the Perl core (== not by the user of the object) are +usually in upper case letters and to avoid collisions with the C +function. + +This setting does not yet influence C in any way, but in the +future, global hooks might get installed that influence C and are +enabled by this setting. + +If C<$enable> is false, then the C setting will decide what +to do when a blessed object is found. + =item $json = $json->shrink ([$enable]) Perl usually over-allocates memory a bit when allocating space for @@ -759,7 +795,7 @@ sub is_bool($) { UNIVERSAL::isa $_[0], "JSON::XS::Boolean" - or UNIVERSAL::isa $_[0], "JSON::Literal" +# or UNIVERSAL::isa $_[0], "JSON::Literal" } XSLoader::load "JSON::XS", $VERSION;