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.18 by root, Tue Aug 28 02:06:06 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 }
272
273 * shell-style '#'-comments
274 Whenever JSON allows whitespace, shell-style comments are
275 additionally allowed. They are terminated by the first
276 carriage-return or line-feed character, after which more
277 white-space and comments are allowed.
278
279 [
280 1, # this comment not allowed in JSON
281 # neither this one...
282 ]
244 283
245 $json = $json->canonical ([$enable]) 284 $json = $json->canonical ([$enable])
246 If $enable is true (or missing), then the "encode" method will 285 If $enable is true (or missing), then the "encode" method will
247 output JSON objects by sorting their keys. This is adding a 286 output JSON objects by sorting their keys. This is adding a
248 comparatively high overhead. 287 comparatively high overhead.
502 A JSON string becomes a string scalar in Perl - Unicode codepoints 541 A JSON string becomes a string scalar in Perl - Unicode codepoints
503 in JSON are represented by the same codepoints in the Perl string, 542 in JSON are represented by the same codepoints in the Perl string,
504 so no manual decoding is necessary. 543 so no manual decoding is necessary.
505 544
506 number 545 number
507 A JSON number becomes either an integer or numeric (floating point) 546 A JSON number becomes either an integer, numeric (floating point) or
508 scalar in perl, depending on its range and any fractional parts. On 547 string scalar in perl, depending on its range and any fractional
509 the Perl level, there is no difference between those as Perl handles 548 parts. On the Perl level, there is no difference between those as
510 all the conversion details, but an integer may take slightly less 549 Perl handles all the conversion details, but an integer may take
511 memory and might represent more values exactly than (floating point) 550 slightly less memory and might represent more values exactly than
512 numbers. 551 (floating point) numbers.
552
553 If the number consists of digits only, JSON::XS will try to
554 represent it as an integer value. If that fails, it will try to
555 represent it as a numeric (floating point) value if that is possible
556 without loss of precision. Otherwise it will preserve the number as
557 a string value.
558
559 Numbers containing a fractional or exponential part will always be
560 represented as numeric (floating point) values, possibly at a loss
561 of precision.
562
563 This might create round-tripping problems as numbers might become
564 strings, but as Perl is typeless there is no other way to do it.
513 565
514 true, false 566 true, false
515 These JSON atoms become "JSON::XS::true" and "JSON::XS::false", 567 These JSON atoms become "JSON::XS::true" and "JSON::XS::false",
516 respectively. They are overloaded to act almost exactly like the 568 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 569 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