ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/XS.pm
(Generate patch)

Comparing JSON-XS/XS.pm (file contents):
Revision 1.107 by root, Tue Jun 3 06:43:45 2008 UTC vs.
Revision 1.108 by root, Tue Jul 15 11:29:29 2008 UTC

103 103
104package JSON::XS; 104package JSON::XS;
105 105
106use strict; 106use strict;
107 107
108our $VERSION = '2.21'; 108our $VERSION = '2.22';
109our @ISA = qw(Exporter); 109our @ISA = qw(Exporter);
110 110
111our @EXPORT = qw(encode_json decode_json to_json from_json); 111our @EXPORT = qw(encode_json decode_json to_json from_json);
112 112
113sub to_json($) { 113sub to_json($) {
706In some cases, there is the need for incremental parsing of JSON 706In some cases, there is the need for incremental parsing of JSON
707texts. While this module always has to keep both JSON text and resulting 707texts. While this module always has to keep both JSON text and resulting
708Perl data structure in memory at one time, it does allow you to parse a 708Perl data structure in memory at one time, it does allow you to parse a
709JSON stream incrementally. It does so by accumulating text until it has 709JSON stream incrementally. It does so by accumulating text until it has
710a full JSON object, which it then can decode. This process is similar to 710a full JSON object, which it then can decode. This process is similar to
711using C<decode_prefix> to see if a full JSON object is available, but is 711using C<decode_prefix> to see if a full JSON object is available, but
712much more efficient (JSON::XS will only attempt to parse the JSON text 712is much more efficient (and can be implemented with a minimum of method
713calls).
714
715JSON::XS will only attempt to parse the JSON text once it is sure it
713once it is sure it has enough text to get a decisive result, using a very 716has enough text to get a decisive result, using a very simple but
714simple but truly incremental parser). 717truly incremental parser. This means that it sometimes won't stop as
718early as the full parser, for example, it doesn't detect parenthese
719mismatches. The only thing it guarantees is that it starts decoding as
720soon as a syntactically valid JSON text has been seen. This means you need
721to set resource limits (e.g. C<max_size>) to ensure the parser will stop
722parsing in the presence if syntax errors.
715 723
716The following two methods deal with this. 724The following methods implement this incremental parser.
717 725
718=over 4 726=over 4
719 727
720=item [void, scalar or list context] = $json->incr_parse ([$string]) 728=item [void, scalar or list context] = $json->incr_parse ([$string])
721 729

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines