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

Comparing JSON-XS/XS.pm (file contents):
Revision 1.58 by root, Sun Aug 26 21:56:47 2007 UTC vs.
Revision 1.61 by root, Wed Sep 12 17:42:36 2007 UTC

277This setting has no effect when decoding JSON texts. 277This setting has no effect when decoding JSON texts.
278 278
279Example, space_before and indent disabled, space_after enabled: 279Example, space_before and indent disabled, space_after enabled:
280 280
281 {"key": "value"} 281 {"key": "value"}
282
283=item $json = $json->relaxed ([$enable])
284
285If C<$enable> is true (or missing), then C<decode> will accept some
286extensions to normal JSON syntax (see below). C<encode> will not be
287affected in anyway. I<Be aware that this option makes you accept invalid
288JSON texts as if they were valid!>. I suggest only to use this option to
289parse application-specific files written by humans (configuration files,
290resource files etc.)
291
292If C<$enable> is false (the default), then C<decode> will only accept
293valid JSON texts.
294
295Currently accepted extensions are:
296
297=over 4
298
299=item * list items can have an end-comma
300
301JSON I<separates> array elements and key-value pairs with commas. This
302can be annoying if you write JSON texts manually and want to be able to
303quickly append elements, so this extension accepts comma at the end of
304such items not just between them:
305
306 [
307 1,
308 2, <- this comma not normally allowed
309 ]
310 {
311 "k1": "v1",
312 "k2": "v2", <- this comma not normally allowed
313 }
314
315=item * shell-style '#'-comments
316
317Whenever JSON allows whitespace, shell-style comments are additionally
318allowed. They are terminated by the first carriage-return or line-feed
319character, after which more white-space and comments are allowed.
320
321 [
322 1, # this comment not allowed in JSON
323 # neither this one...
324 ]
325
326=back
282 327
283=item $json = $json->canonical ([$enable]) 328=item $json = $json->canonical ([$enable])
284 329
285If C<$enable> is true (or missing), then the C<encode> method will output JSON objects 330If C<$enable> is true (or missing), then the C<encode> method will output JSON objects
286by sorting their keys. This is adding a comparatively high overhead. 331by sorting their keys. This is adding a comparatively high overhead.
621 to_json [\0,JSON::XS::true] # yields [false,true] 666 to_json [\0,JSON::XS::true] # yields [false,true]
622 667
623=item JSON::XS::true, JSON::XS::false 668=item JSON::XS::true, JSON::XS::false
624 669
625These special values become JSON true and JSON false values, 670These special values become JSON true and JSON false values,
626respectively. You cna alos use C<\1> and C<\0> directly if you want. 671respectively. You can also use C<\1> and C<\0> directly if you want.
627 672
628=item blessed objects 673=item blessed objects
629 674
630Blessed objects are not allowed. JSON::XS currently tries to encode their 675Blessed objects are not allowed. JSON::XS currently tries to encode their
631underlying representation (hash- or arrayref), but this behaviour might 676underlying representation (hash- or arrayref), but this behaviour might

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines