… | |
… | |
84 | |
84 | |
85 | package JSON::XS; |
85 | package JSON::XS; |
86 | |
86 | |
87 | use strict; |
87 | use strict; |
88 | |
88 | |
89 | our $VERSION = '1.53'; |
89 | our $VERSION = '2.0'; |
90 | our @ISA = qw(Exporter); |
90 | our @ISA = qw(Exporter); |
91 | |
91 | |
92 | our @EXPORT = qw(to_json from_json); |
92 | our @EXPORT = qw(to_json from_json); |
93 | |
93 | |
94 | use Exporter; |
94 | use Exporter; |
… | |
… | |
276 | |
276 | |
277 | use Encode; |
277 | use Encode; |
278 | $object = JSON::XS->new->decode (decode "UTF-32LE", $jsontext); |
278 | $object = JSON::XS->new->decode (decode "UTF-32LE", $jsontext); |
279 | |
279 | |
280 | =item $json = $json->pretty ([$enable]) |
280 | =item $json = $json->pretty ([$enable]) |
281 | |
|
|
282 | =item $enabled = $json->get_pretty |
|
|
283 | |
281 | |
284 | This enables (or disables) all of the C<indent>, C<space_before> and |
282 | This enables (or disables) all of the C<indent>, C<space_before> and |
285 | C<space_after> (and in the future possibly more) flags in one call to |
283 | C<space_after> (and in the future possibly more) flags in one call to |
286 | generate the most readable (or most compact) form possible. |
284 | generate the most readable (or most compact) form possible. |
287 | |
285 | |
… | |
… | |
429 | JSON::XS->new->allow_nonref->encode ("Hello, World!") |
427 | JSON::XS->new->allow_nonref->encode ("Hello, World!") |
430 | => "Hello, World!" |
428 | => "Hello, World!" |
431 | |
429 | |
432 | =item $json = $json->allow_blessed ([$enable]) |
430 | =item $json = $json->allow_blessed ([$enable]) |
433 | |
431 | |
434 | =item $enabled = $json->get_allow_bless |
432 | =item $enabled = $json->get_allow_blessed |
435 | |
433 | |
436 | If C<$enable> is true (or missing), then the C<encode> method will not |
434 | If C<$enable> is true (or missing), then the C<encode> method will not |
437 | barf when it encounters a blessed reference. Instead, the value of the |
435 | barf when it encounters a blessed reference. Instead, the value of the |
438 | B<convert_blessed> option will decide whether C<null> (C<convert_blessed> |
436 | B<convert_blessed> option will decide whether C<null> (C<convert_blessed> |
439 | disabled or no C<to_json> method found) or a representation of the |
437 | disabled or no C<TO_JSON> method found) or a representation of the |
440 | object (C<convert_blessed> enabled and C<to_json> method found) is being |
438 | object (C<convert_blessed> enabled and C<TO_JSON> method found) is being |
441 | encoded. Has no effect on C<decode>. |
439 | encoded. Has no effect on C<decode>. |
442 | |
440 | |
443 | If C<$enable> is false (the default), then C<encode> will throw an |
441 | If C<$enable> is false (the default), then C<encode> will throw an |
444 | exception when it encounters a blessed object. |
442 | exception when it encounters a blessed object. |
445 | |
443 | |