… | |
… | |
502 | A JSON string becomes a string scalar in Perl - Unicode codepoints |
502 | A JSON string becomes a string scalar in Perl - Unicode codepoints |
503 | in JSON are represented by the same codepoints in the Perl string, |
503 | in JSON are represented by the same codepoints in the Perl string, |
504 | so no manual decoding is necessary. |
504 | so no manual decoding is necessary. |
505 | |
505 | |
506 | number |
506 | number |
507 | A JSON number becomes either an integer or numeric (floating point) |
507 | A JSON number becomes either an integer, numeric (floating point) or |
508 | scalar in perl, depending on its range and any fractional parts. On |
508 | string scalar in perl, depending on its range and any fractional |
509 | the Perl level, there is no difference between those as Perl handles |
509 | parts. On the Perl level, there is no difference between those as |
510 | all the conversion details, but an integer may take slightly less |
510 | Perl handles all the conversion details, but an integer may take |
511 | memory and might represent more values exactly than (floating point) |
511 | slightly less memory and might represent more values exactly than |
512 | numbers. |
512 | (floating point) numbers. |
|
|
513 | |
|
|
514 | If the number consists of digits only, JSON::XS will try to |
|
|
515 | represent it as an integer value. If that fails, it will try to |
|
|
516 | represent it as a numeric (floating point) value if that is possible |
|
|
517 | without loss of precision. Otherwise it will preserve the number as |
|
|
518 | a string value. |
|
|
519 | |
|
|
520 | Numbers containing a fractional or exponential part will always be |
|
|
521 | represented as numeric (floating point) values, possibly at a loss |
|
|
522 | of precision. |
|
|
523 | |
|
|
524 | This might create round-tripping problems as numbers might become |
|
|
525 | strings, but as Perl is typeless there is no other way to do it. |
513 | |
526 | |
514 | true, false |
527 | true, false |
515 | These JSON atoms become "JSON::XS::true" and "JSON::XS::false", |
528 | These JSON atoms become "JSON::XS::true" and "JSON::XS::false", |
516 | respectively. They are overloaded to act almost exactly like the |
529 | 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 |
530 | numbers 1 and 0. You can check wether a scalar is a JSON boolean by |