ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/JSON-XS/README
(Generate patch)

Comparing JSON-XS/README (file contents):
Revision 1.34 by root, Thu Mar 11 17:36:09 2010 UTC vs.
Revision 1.35 by root, Thu Mar 11 19:31:37 2010 UTC

56 does so, and even documents what "correct" means. 56 does so, and even documents what "correct" means.
57 57
58 * round-trip integrity 58 * round-trip integrity
59 59
60 When you serialise a perl data structure using only data types 60 When you serialise a perl data structure using only data types
61 supported by JSON, the deserialised data structure is identical on 61 supported by JSON and Perl, the deserialised data structure is
62 the Perl level. (e.g. the string "2.0" doesn't suddenly become "2" 62 identical on the Perl level. (e.g. the string "2.0" doesn't suddenly
63 just because it looks like a number). There minor *are* exceptions 63 become "2" just because it looks like a number). There *are* minor
64 to this, read the MAPPING section below to learn about those. 64 exceptions to this, read the MAPPING section below to learn about
65 those.
65 66
66 * strict checking of JSON correctness 67 * strict checking of JSON correctness
67 68
68 There is no guessing, no generating of illegal JSON texts by 69 There is no guessing, no generating of illegal JSON texts by
69 default, and only JSON is accepted as input by default (the latter 70 default, and only JSON is accepted as input by default (the latter
670 JSON objects or arrays, instead they must be concatenated 671 JSON objects or arrays, instead they must be concatenated
671 back-to-back. If an error occurs, an exception will be raised as in 672 back-to-back. If an error occurs, an exception will be raised as in
672 the scalar context case. Note that in this case, any 673 the scalar context case. Note that in this case, any
673 previously-parsed JSON texts will be lost. 674 previously-parsed JSON texts will be lost.
674 675
676 Example: Parse some JSON arrays/objects in a given string and return
677 them.
678
679 my @objs = JSON::XS->new->incr_parse ("[5][7][1,2]");
680
675 $lvalue_string = $json->incr_text 681 $lvalue_string = $json->incr_text
676 This method returns the currently stored JSON fragment as an lvalue, 682 This method returns the currently stored JSON fragment as an lvalue,
677 that is, you can manipulate it. This *only* works when a preceding 683 that is, you can manipulate it. This *only* works when a preceding
678 call to "incr_parse" in *scalar context* successfully returned an 684 call to "incr_parse" in *scalar context* successfully returned an
679 object. Under all other circumstances you must not call this 685 object. Under all other circumstances you must not call this
893 Numbers containing a fractional or exponential part will always be 899 Numbers containing a fractional or exponential part will always be
894 represented as numeric (floating point) values, possibly at a loss 900 represented as numeric (floating point) values, possibly at a loss
895 of precision (in which case you might lose perfect roundtripping 901 of precision (in which case you might lose perfect roundtripping
896 ability, but the JSON number will still be re-encoded as a JSON 902 ability, but the JSON number will still be re-encoded as a JSON
897 number). 903 number).
904
905 Note that precision is not accuracy - binary floating point values
906 cannot represent most decimal fractions exactly, and when converting
907 from and to floating point, JSON::XS only guarantees precision up to
908 but not including the leats significant bit.
898 909
899 true, false 910 true, false
900 These JSON atoms become "JSON::XS::true" and "JSON::XS::false", 911 These JSON atoms become "JSON::XS::true" and "JSON::XS::false",
901 respectively. They are overloaded to act almost exactly like the 912 respectively. They are overloaded to act almost exactly like the
902 numbers 1 and 0. You can check whether a scalar is a JSON boolean by 913 numbers 1 and 0. You can check whether a scalar is a JSON boolean by
979 990
980 You can not currently force the type in other, less obscure, ways. 991 You can not currently force the type in other, less obscure, ways.
981 Tell me if you need this capability (but don't forget to explain why 992 Tell me if you need this capability (but don't forget to explain why
982 it's needed :). 993 it's needed :).
983 994
995 Note that numerical precision has the same meaning as under Perl (so
996 binary to decimal conversion follows the same rules as in Perl,
997 which can differ to other languages). Also, your perl interpreter
998 might expose extensions to the floating point numbers of your
999 platform, such as infinities or NaN's - these cannot be represented
1000 in JSON, and it is an error to pass those in.
1001
984ENCODING/CODESET FLAG NOTES 1002ENCODING/CODESET FLAG NOTES
985 The interested reader might have seen a number of flags that signify 1003 The interested reader might have seen a number of flags that signify
986 encodings or codesets - "utf8", "latin1" and "ascii". There seems to be 1004 encodings or codesets - "utf8", "latin1" and "ascii". There seems to be
987 some confusion on what these do, so here is a short comparison: 1005 some confusion on what these do, so here is a short comparison:
988 1006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines