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.27 by root, Tue Apr 3 01:25:40 2007 UTC vs.
Revision 1.28 by root, Tue Apr 3 23:59:04 2007 UTC

86package JSON::XS; 86package JSON::XS;
87 87
88use strict; 88use strict;
89 89
90BEGIN { 90BEGIN {
91 our $VERSION = '1.02'; 91 our $VERSION = '1.1';
92 our @ISA = qw(Exporter); 92 our @ISA = qw(Exporter);
93 93
94 our @EXPORT = qw(to_json from_json objToJson jsonToObj); 94 our @EXPORT = qw(to_json from_json objToJson jsonToObj);
95 require Exporter; 95 require Exporter;
96 96
309strings that look like integers or floats into integers or floats 309strings that look like integers or floats into integers or floats
310internally (there is no difference on the Perl level), saving space. 310internally (there is no difference on the Perl level), saving space.
311 311
312=item $json = $json->max_depth ([$maximum_nesting_depth]) 312=item $json = $json->max_depth ([$maximum_nesting_depth])
313 313
314Sets the maximum nesting level (default C<4096>) accepted while encoding 314Sets the maximum nesting level (default C<512>) accepted while encoding
315or decoding. If the JSON text or Perl data structure has an equal or 315or decoding. If the JSON text or Perl data structure has an equal or
316higher nesting level then this limit, then the encoder and decoder will 316higher nesting level then this limit, then the encoder and decoder will
317stop and croak at that point. 317stop and croak at that point.
318 318
319Nesting level is defined by number of hash- or arrayrefs that the encoder 319Nesting level is defined by number of hash- or arrayrefs that the encoder
632usually a good indication of the size of the resources required to decode 632usually a good indication of the size of the resources required to decode
633it into a Perl structure. 633it into a Perl structure.
634 634
635Third, JSON::XS recurses using the C stack when decoding objects and 635Third, JSON::XS recurses using the C stack when decoding objects and
636arrays. The C stack is a limited resource: for instance, on my amd64 636arrays. The C stack is a limited resource: for instance, on my amd64
637machine with 8MB of stack size I can decode around 180k nested arrays 637machine with 8MB of stack size I can decode around 180k nested arrays but
638but only 14k nested JSON objects. If that is exceeded, the program 638only 14k nested JSON objects (due to perl itself recursing deeply on croak
639crashes. Thats why the default nesting limit is set to 4096. If your 639to free the temporary). If that is exceeded, the program crashes. to be
640conservative, the default nesting limit is set to 512. If your process
640process has a smaller stack, you should adjust this setting accordingly 641has a smaller stack, you should adjust this setting accordingly with the
641with the C<max_depth> method. 642C<max_depth> method.
642 643
643And last but least, something else could bomb you that I forgot to think 644And last but least, something else could bomb you that I forgot to think
644of. In that case, you get to keep the pieces. I am alway sopen for hints, 645of. In that case, you get to keep the pieces. I am alway sopen for hints,
645though... 646though...
646 647

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines