… | |
… | |
683 | =back |
683 | =back |
684 | |
684 | |
685 | |
685 | |
686 | =head1 INCREMENTAL PARSING |
686 | =head1 INCREMENTAL PARSING |
687 | |
687 | |
688 | [This section is still EXPERIMENTAL] |
688 | [This section and the API it details is still EXPERIMENTAL] |
689 | |
689 | |
690 | In some cases, there is the need for incremental parsing of JSON |
690 | In some cases, there is the need for incremental parsing of JSON |
691 | texts. While this module always has to keep both JSON text and resulting |
691 | texts. While this module always has to keep both JSON text and resulting |
692 | Perl data structure in memory at one time, it does allow you to parse a |
692 | Perl data structure in memory at one time, it does allow you to parse a |
693 | JSON stream incrementally. It does so by accumulating text until it has |
693 | JSON stream incrementally. It does so by accumulating text until it has |
… | |
… | |
727 | objects or arrays, instead they must be concatenated back-to-back. If |
727 | objects or arrays, instead they must be concatenated back-to-back. If |
728 | an error occurs, an exception will be raised as in the scalar context |
728 | an error occurs, an exception will be raised as in the scalar context |
729 | case. Note that in this case, any previously-parsed JSON texts will be |
729 | case. Note that in this case, any previously-parsed JSON texts will be |
730 | lost. |
730 | lost. |
731 | |
731 | |
732 | If there is a parse |
|
|
733 | |
|
|
734 | =item $lvalue_string = $json->incr_text |
732 | =item $lvalue_string = $json->incr_text |
735 | |
733 | |
736 | This method returns the currently stored JSON fragment as an lvalue, that |
734 | This method returns the currently stored JSON fragment as an lvalue, that |
737 | is, you can manipulate it. This I<only> works when a preceding call to |
735 | is, you can manipulate it. This I<only> works when a preceding call to |
738 | C<incr_parse> in I<scalar context> successfully returned an object. Under |
736 | C<incr_parse> in I<scalar context> successfully returned an object. Under |
… | |
… | |
742 | method before having parsed anything. |
740 | method before having parsed anything. |
743 | |
741 | |
744 | This function is useful in two cases: a) finding the trailing text after a |
742 | This function is useful in two cases: a) finding the trailing text after a |
745 | JSON object or b) parsing multiple JSON objects separated by non-JSON text |
743 | JSON object or b) parsing multiple JSON objects separated by non-JSON text |
746 | (such as commas). |
744 | (such as commas). |
|
|
745 | |
|
|
746 | =item $json->incr_skip |
|
|
747 | |
|
|
748 | This will reset the state of the incremental parser and will remove the |
|
|
749 | parsed text from the input buffer. This is useful after C<incr_parse> |
|
|
750 | died, in which case the input buffer and incremental parser state is left |
|
|
751 | unchanged, to skip the text parsed so far and to reset the parse state. |
747 | |
752 | |
748 | =back |
753 | =back |
749 | |
754 | |
750 | =head2 LIMITATIONS |
755 | =head2 LIMITATIONS |
751 | |
756 | |