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