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

Comparing JSON-XS/README (file contents):
Revision 1.15 by root, Mon Jul 2 08:06:48 2007 UTC vs.
Revision 1.17 by root, Mon Aug 27 02:03:23 2007 UTC

239 This setting has no effect when decoding JSON texts. 239 This setting has no effect when decoding JSON texts.
240 240
241 Example, space_before and indent disabled, space_after enabled: 241 Example, space_before and indent disabled, space_after enabled:
242 242
243 {"key": "value"} 243 {"key": "value"}
244
245 $json = $json->relaxed ([$enable])
246 If $enable is true (or missing), then "decode" will accept some
247 extensions to normal JSON syntax (see below). "encode" will not be
248 affected in anyway. *Be aware that this option makes you accept
249 invalid JSON texts as if they were valid!*. I suggest only to use
250 this option to parse application-specific files written by humans
251 (configuration files, resource files etc.)
252
253 If $enable is false (the default), then "decode" will only accept
254 valid JSON texts.
255
256 Currently accepted extensions are:
257
258 * list items can have an end-comma
259 JSON *separates* array elements and key-value pairs with commas.
260 This can be annoying if you write JSON texts manually and want
261 to be able to quickly append elements, so this extension accepts
262 comma at the end of such items not just between them:
263
264 [
265 1,
266 2, <- this comma not normally allowed
267 ]
268 {
269 "k1": "v1",
270 "k2": "v2", <- this comma not normally allowed
271 }
244 272
245 $json = $json->canonical ([$enable]) 273 $json = $json->canonical ([$enable])
246 If $enable is true (or missing), then the "encode" method will 274 If $enable is true (or missing), then the "encode" method will
247 output JSON objects by sorting their keys. This is adding a 275 output JSON objects by sorting their keys. This is adding a
248 comparatively high overhead. 276 comparatively high overhead.
502 A JSON string becomes a string scalar in Perl - Unicode codepoints 530 A JSON string becomes a string scalar in Perl - Unicode codepoints
503 in JSON are represented by the same codepoints in the Perl string, 531 in JSON are represented by the same codepoints in the Perl string,
504 so no manual decoding is necessary. 532 so no manual decoding is necessary.
505 533
506 number 534 number
507 A JSON number becomes either an integer or numeric (floating point) 535 A JSON number becomes either an integer, numeric (floating point) or
508 scalar in perl, depending on its range and any fractional parts. On 536 string scalar in perl, depending on its range and any fractional
509 the Perl level, there is no difference between those as Perl handles 537 parts. On the Perl level, there is no difference between those as
510 all the conversion details, but an integer may take slightly less 538 Perl handles all the conversion details, but an integer may take
511 memory and might represent more values exactly than (floating point) 539 slightly less memory and might represent more values exactly than
512 numbers. 540 (floating point) numbers.
541
542 If the number consists of digits only, JSON::XS will try to
543 represent it as an integer value. If that fails, it will try to
544 represent it as a numeric (floating point) value if that is possible
545 without loss of precision. Otherwise it will preserve the number as
546 a string value.
547
548 Numbers containing a fractional or exponential part will always be
549 represented as numeric (floating point) values, possibly at a loss
550 of precision.
551
552 This might create round-tripping problems as numbers might become
553 strings, but as Perl is typeless there is no other way to do it.
513 554
514 true, false 555 true, false
515 These JSON atoms become "JSON::XS::true" and "JSON::XS::false", 556 These JSON atoms become "JSON::XS::true" and "JSON::XS::false",
516 respectively. They are overloaded to act almost exactly like the 557 respectively. They are overloaded to act almost exactly like the
517 numbers 1 and 0. You can check wether a scalar is a JSON boolean by 558 numbers 1 and 0. You can check wether a scalar is a JSON boolean by

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines