--- JSON-XS/XS.pm 2008/05/24 21:55:43 1.105 +++ JSON-XS/XS.pm 2008/07/19 04:21:32 1.109 @@ -105,7 +105,7 @@ use strict; -our $VERSION = '2.2'; +our $VERSION = '2.222'; our @ISA = qw(Exporter); our @EXPORT = qw(encode_json decode_json to_json from_json); @@ -708,12 +708,20 @@ Perl data structure in memory at one time, it does allow you to parse a JSON stream incrementally. It does so by accumulating text until it has a full JSON object, which it then can decode. This process is similar to -using C to see if a full JSON object is available, but is -much more efficient (JSON::XS will only attempt to parse the JSON text -once it is sure it has enough text to get a decisive result, using a very -simple but truly incremental parser). +using C to see if a full JSON object is available, but +is much more efficient (and can be implemented with a minimum of method +calls). + +JSON::XS will only attempt to parse the JSON text once it is sure it +has enough text to get a decisive result, using a very simple but +truly incremental parser. This means that it sometimes won't stop as +early as the full parser, for example, it doesn't detect parenthese +mismatches. The only thing it guarantees is that it starts decoding as +soon as a syntactically valid JSON text has been seen. This means you need +to set resource limits (e.g. C) to ensure the parser will stop +parsing in the presence if syntax errors. -The following two methods deal with this. +The following methods implement this incremental parser. =over 4 @@ -766,6 +774,15 @@ 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. +=item $json->incr_reset + +This completely resets the incremental parser, that is, after this call, +it will be as if the parser had never parsed anything. + +This is useful if you want ot repeatedly parse JSON objects and want to +ignore any trailing data, which means you have to reset the parser after +each successful decode. + =back =head2 LIMITATIONS