… | |
… | |
673 | when there is trailing garbage after the first JSON object, it will |
673 | when there is trailing garbage after the first JSON object, it will |
674 | silently stop parsing there and return the number of characters consumed |
674 | silently stop parsing there and return the number of characters consumed |
675 | so far. |
675 | so far. |
676 | |
676 | |
677 | This is useful if your JSON texts are not delimited by an outer protocol |
677 | This is useful if your JSON texts are not delimited by an outer protocol |
678 | (which is not the brightest thing to do in the first place) and you need |
|
|
679 | to know where the JSON text ends. |
678 | and you need to know where the JSON text ends. |
680 | |
679 | |
681 | JSON::XS->new->decode_prefix ("[1] the tail") |
680 | JSON::XS->new->decode_prefix ("[1] the tail") |
682 | => ([], 3) |
681 | => ([], 3) |
683 | |
682 | |
684 | =back |
683 | =back |
… | |
… | |
778 | =back |
777 | =back |
779 | |
778 | |
780 | =head2 LIMITATIONS |
779 | =head2 LIMITATIONS |
781 | |
780 | |
782 | All options that affect decoding are supported, except |
781 | All options that affect decoding are supported, except |
783 | C<allow_nonref>. The reason for this is that it cannot be made to |
782 | C<allow_nonref>. The reason for this is that it cannot be made to work |
784 | work sensibly: JSON objects and arrays are self-delimited, i.e. you can concatenate |
783 | sensibly: JSON objects and arrays are self-delimited, i.e. you can |
785 | them back to back and still decode them perfectly. This does not hold true |
784 | concatenate them back to back and still decode them perfectly. This does |
786 | for JSON numbers, however. |
785 | not hold true for JSON numbers, however. |
787 | |
786 | |
788 | For example, is the string C<1> a single JSON number, or is it simply the |
787 | For example, is the string C<1> a single JSON number, or is it simply the |
789 | start of C<12>? Or is C<12> a single JSON number, or the concatenation |
788 | start of C<12>? Or is C<12> a single JSON number, or the concatenation |
790 | of C<1> and C<2>? In neither case you can tell, and this is why JSON::XS |
789 | of C<1> and C<2>? In neither case you can tell, and this is why JSON::XS |
791 | takes the conservative route and disallows this case. |
790 | takes the conservative route and disallows this case. |