--- JSON-XS/XS.pm 2013/10/29 00:06:40 1.145 +++ JSON-XS/XS.pm 2013/10/29 00:21:10 1.149 @@ -469,26 +469,28 @@ =item $enabled = $json->get_allow_blessed +See L for details. + 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 whether 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. +barf when it encounters a blessed reference that it cannot convert +otherwise. Instead, a JSON C value is encoded instead of the object. If C<$enable> is false (the default), then C will throw an -exception when it encounters a blessed object. +exception when it encounters a blessed object that it cannot convert +otherwise. + +This setting has no effect on C. =item $json = $json->convert_blessed ([$enable]) =item $enabled = $json->get_convert_blessed +See L for details. + 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. +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. The C method may safely call die if it wants. If C returns other blessed objects, those will be handled in the same @@ -498,12 +500,28 @@ usually in upper case letters and to avoid collisions with any C function or method. -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 (the default), then C will not consider +this type of conversion. + +This setting has no effect on C. -If C<$enable> is false, then the C setting will decide what -to do when a blessed object is found. +=item $json = $json->allow_tags ([$enable]) + +=item $enabled = $json->allow_tags + +See L for details. + +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 used to serialise the object into +a nonstandard tagged JSON value (that JSON decoders cannot decode). + +It also causes C to parse such tagged JSON values and deserialise +them via a call to the C method. + +If C<$enable> is false (the default), then C will not consider +this type of conversion, and tagged JSON values will cause a parse error +in C, as if tags were not part of the grammar. =item $json = $json->filter_json_object ([$coderef->($hashref)]) @@ -1001,7 +1019,7 @@ I must be a perl package/class name encoded as a JSON string, and the I must be a JSON array encoding optional constructor arguments. -See "OBJECT SERIALISATION", below, for details. +See L, below, for details. =back @@ -1050,7 +1068,7 @@ =item blessed objects Blessed objects are not directly representable in JSON, but C -allows various ways of handling objects. See "OBJECT SERIALISATION", +allows various ways of handling objects. See L, below, for details. =item simple scalars @@ -1113,7 +1131,7 @@ =over 4 -=item 1. C is enabled and object has a C method. +=item 1. C is enabled and the object has a C method. In this case, C uses the L object serialisation protocol to create a tagged JSON value, using a nonstandard @@ -1138,7 +1156,7 @@ ($self->{type}, $self->{id}) } -=item 2. C is enabled and object has a C method. +=item 2. C is enabled and the object has a C method. In this case, the C method of the object is invoked in scalar context. It must return a single scalar that can be directly encoded into @@ -1178,8 +1196,9 @@ error will result (as if tagged values were not part of the grammar). If C is enabled, C will look up the C method -of the package/classname used during serialisation. If there is no such -method, the decoding will fail with an error. +of the package/classname used during serialisation (it will not attempt +to load the package as a Perl module). If there is no such method, the +decoding will fail with an error. Otherwise, the C method is invoked with the classname as first argument, the constant string C as second argument, and all the