… | |
… | |
265 | converting strings that look like integers or floats into integers |
265 | converting strings that look like integers or floats into integers |
266 | or floats internally (there is no difference on the Perl level), |
266 | or floats internally (there is no difference on the Perl level), |
267 | saving space. |
267 | saving space. |
268 | |
268 | |
269 | $json = $json->max_depth ([$maximum_nesting_depth]) |
269 | $json = $json->max_depth ([$maximum_nesting_depth]) |
270 | Sets the maximum nesting level (default 4096) accepted while |
270 | Sets the maximum nesting level (default 512) accepted while encoding |
271 | encoding or decoding. If the JSON text or Perl data structure has an |
271 | or decoding. If the JSON text or Perl data structure has an equal or |
272 | equal or higher nesting level then this limit, then the encoder and |
272 | higher nesting level then this limit, then the encoder and decoder |
273 | decoder will stop and croak at that point. |
273 | will stop and croak at that point. |
274 | |
274 | |
275 | Nesting level is defined by number of hash- or arrayrefs that the |
275 | Nesting level is defined by number of hash- or arrayrefs that the |
276 | encoder needs to traverse to reach a given point or the number of |
276 | encoder needs to traverse to reach a given point or the number of |
277 | "{" or "[" characters without their matching closing parenthesis |
277 | "{" or "[" characters without their matching closing parenthesis |
278 | crossed to reach a given character in a string. |
278 | crossed to reach a given character in a string. |
… | |
… | |
411 | $x *= 1; # same thing, the choise is yours. |
411 | $x *= 1; # same thing, the choise is yours. |
412 | |
412 | |
413 | You can not currently output JSON booleans or force the type in |
413 | You can not currently output JSON booleans or force the type in |
414 | other, less obscure, ways. Tell me if you need this capability. |
414 | other, less obscure, ways. Tell me if you need this capability. |
415 | |
415 | |
416 | circular data structures |
|
|
417 | Those will be encoded until memory or stackspace runs out. |
|
|
418 | |
|
|
419 | COMPARISON |
416 | COMPARISON |
420 | As already mentioned, this module was created because none of the |
417 | As already mentioned, this module was created because none of the |
421 | existing JSON modules could be made to work correctly. First I will |
418 | existing JSON modules could be made to work correctly. First I will |
422 | describe the problems (or pleasures) I encountered with various existing |
419 | describe the problems (or pleasures) I encountered with various existing |
423 | JSON modules, followed by some benchmark values. JSON::XS was designed |
420 | JSON modules, followed by some benchmark values. JSON::XS was designed |
… | |
… | |
561 | required to decode it into a Perl structure. |
558 | required to decode it into a Perl structure. |
562 | |
559 | |
563 | Third, JSON::XS recurses using the C stack when decoding objects and |
560 | Third, JSON::XS recurses using the C stack when decoding objects and |
564 | arrays. The C stack is a limited resource: for instance, on my amd64 |
561 | arrays. The C stack is a limited resource: for instance, on my amd64 |
565 | machine with 8MB of stack size I can decode around 180k nested arrays |
562 | machine with 8MB of stack size I can decode around 180k nested arrays |
566 | but only 14k nested JSON objects. If that is exceeded, the program |
563 | but only 14k nested JSON objects (due to perl itself recursing deeply on |
|
|
564 | croak to free the temporary). If that is exceeded, the program crashes. |
567 | crashes. Thats why the default nesting limit is set to 4096. If your |
565 | to be conservative, the default nesting limit is set to 512. If your |
568 | process has a smaller stack, you should adjust this setting accordingly |
566 | process has a smaller stack, you should adjust this setting accordingly |
569 | with the "max_depth" method. |
567 | with the "max_depth" method. |
570 | |
568 | |
571 | And last but least, something else could bomb you that I forgot to think |
569 | And last but least, something else could bomb you that I forgot to think |
572 | of. In that case, you get to keep the pieces. I am alway sopen for |
570 | of. In that case, you get to keep the pieces. I am alway sopen for |