--- JSON-XS/XS.pm 2008/03/25 16:56:09 1.95 +++ JSON-XS/XS.pm 2008/03/27 06:37:35 1.99 @@ -105,7 +105,7 @@ use strict; -our $VERSION = '2.1'; +our $VERSION = '2.2'; our @ISA = qw(Exporter); our @EXPORT = qw(encode_json decode_json to_json from_json); @@ -465,6 +465,22 @@ JSON::XS->new->allow_nonref->encode ("Hello, World!") => "Hello, World!" +=item $json = $json->allow_unknown ([$enable]) + +=item $enabled = $json->get_allow_unknown + +If C<$enable> is true (or missing), then C will I throw an +exception when it encounters values it cannot represent in JSON (for +example, filehandles) but instead will encode a JSON C value. Note +that blessed objects are not included here and are handled separately by +c. + +If C<$enable> is false (the default), then C will throw an +exception when it encounters anything it cannot encode as JSON. + +This option does not affect C in any way, and it is recommended to +leave it off unless you know your communications partner. + =item $json = $json->allow_blessed ([$enable]) =item $enabled = $json->get_allow_blessed @@ -685,7 +701,7 @@ =head1 INCREMENTAL PARSING -[This section is still EXPERIMENTAL] +[This section and the API it details is still EXPERIMENTAL] In some cases, there is the need for incremental parsing of JSON texts. While this module always has to keep both JSON text and resulting @@ -716,13 +732,18 @@ If the method is called in scalar context, then it will try to extract exactly I JSON object. If that is successful, it will return this -object, otherwise it will return C. This is the most common way of +object, otherwise it will return C. If there is a parse error, +this method will croak just as C would do (one can then use +C to skip the errornous part). This is the most common way of using the method. And finally, in list context, it will try to extract as many objects from the stream as it can find and return them, or the empty list otherwise. For this to work, there must be no separators between the JSON -objects or arrays, instead they must be concatenated back-to-back. +objects or arrays, instead they must be concatenated back-to-back. If +an error occurs, an exception will be raised as in the scalar context +case. Note that in this case, any previously-parsed JSON texts will be +lost. =item $lvalue_string = $json->incr_text @@ -738,6 +759,13 @@ JSON object or b) parsing multiple JSON objects separated by non-JSON text (such as commas). +=item $json->incr_skip + +This will reset the state of the incremental parser and will remove the +parsed text from the input buffer. This is useful after C +died, in which case the input buffer and incremental parser state is left +unchanged, to skip the text parsed so far and to reset the parse state. + =back =head2 LIMITATIONS