… | |
… | |
81 | |
81 | |
82 | package JSON::XS; |
82 | package JSON::XS; |
83 | |
83 | |
84 | use strict; |
84 | use strict; |
85 | |
85 | |
86 | our $VERSION = '1.42'; |
86 | our $VERSION = '1.5'; |
87 | our @ISA = qw(Exporter); |
87 | our @ISA = qw(Exporter); |
88 | |
88 | |
89 | our @EXPORT = qw(to_json from_json); |
89 | our @EXPORT = qw(to_json from_json); |
90 | |
90 | |
91 | use Exporter; |
91 | use Exporter; |
… | |
… | |
553 | are represented by the same codepoints in the Perl string, so no manual |
553 | are represented by the same codepoints in the Perl string, so no manual |
554 | decoding is necessary. |
554 | decoding is necessary. |
555 | |
555 | |
556 | =item number |
556 | =item number |
557 | |
557 | |
558 | A JSON number becomes either an integer or numeric (floating point) |
558 | A JSON number becomes either an integer, numeric (floating point) or |
559 | scalar in perl, depending on its range and any fractional parts. On the |
559 | string scalar in perl, depending on its range and any fractional parts. On |
560 | Perl level, there is no difference between those as Perl handles all the |
560 | the Perl level, there is no difference between those as Perl handles all |
561 | conversion details, but an integer may take slightly less memory and might |
561 | the conversion details, but an integer may take slightly less memory and |
562 | represent more values exactly than (floating point) numbers. |
562 | might represent more values exactly than (floating point) numbers. |
|
|
563 | |
|
|
564 | If the number consists of digits only, JSON::XS will try to represent |
|
|
565 | it as an integer value. If that fails, it will try to represent it as |
|
|
566 | a numeric (floating point) value if that is possible without loss of |
|
|
567 | precision. Otherwise it will preserve the number as a string value. |
|
|
568 | |
|
|
569 | Numbers containing a fractional or exponential part will always be |
|
|
570 | represented as numeric (floating point) values, possibly at a loss of |
|
|
571 | precision. |
|
|
572 | |
|
|
573 | This might create round-tripping problems as numbers might become strings, |
|
|
574 | but as Perl is typeless there is no other way to do it. |
563 | |
575 | |
564 | =item true, false |
576 | =item true, false |
565 | |
577 | |
566 | These JSON atoms become C<JSON::XS::true> and C<JSON::XS::false>, |
578 | These JSON atoms become C<JSON::XS::true> and C<JSON::XS::false>, |
567 | respectively. They are overloaded to act almost exactly like the numbers |
579 | respectively. They are overloaded to act almost exactly like the numbers |