JSON5

 view release on metacpan or  search on metacpan

lib/JSON5.pm  view on Meta::CPAN

   => JSON::PP::true

=head2 utf8

    $json5 = $json5->utf8([$enable])
    
    $enabled = $json5->get_utf8

If $enable is true (or missing), then the decode method expects to be handled
an UTF-8-encoded string. Please note that UTF-8-encoded strings do not contain any
characters outside the range 0..255, they are thus useful for bytewise/binary I/O.

(In Perl 5.005, any character outside the range 0..255 does not exist.
See to L<UNICODE HANDLING ON PERLS>.)

In future versions, enabling this option might enable auto-detection of the UTF-16 and UTF-32
encoding families, as described in RFC4627.

If $enable is false, then the decode expects thus a Unicode string. Any decoding
(e.g. to UTF-8 or UTF-16) needs to be done yourself, e.g. using the Encode module.

Example, decode UTF-32LE-encoded JSON5:

  use Encode;
  $object = JSON5->new->decode (decode "UTF-32LE", $json5text);

=head2 allow_nonref

    $json5 = $json5->allow_nonref([$enable])
    
    $enabled = $json5->get_allow_nonref

If C<$enable> is true (or missing), then the C<decode> method will accept a
non-reference into its corresponding string, number or null JSON5 value,
which is an extension to RFC4627.

If C<$enable> is false, then the C<decode> method will croak if
given something that is not a JSON5 object or array.

=head2 max_size

    $json5 = $json5->max_size([$maximum_string_size])
    
    $max_size = $json5->get_max_size

Set the maximum length a JSON5 text may have (in bytes) where decoding is
being attempted. The default is C<0>, meaning no limit. When C<decode>
is called on a string that is longer then this many bytes, it will not
attempt to decode the string but throw an exception.

If no argument is given, the limit check will be deactivated (same as when
C<0> is specified).

=head2 decode

    $perl_scalar = $json5->decode($json5_text)

JSON5 numbers and strings become simple Perl scalars. JSON5 arrays become
Perl arrayrefs and JSON5 objects become Perl hashrefs. C<true> becomes
C<1> (C<JSON::PP::true>), C<false> becomes C<0> (C<JSON::PP::false>),
C<NaN> becomes C<'NaN'>, C<Infinity> becomes C<'Inf'>, and
C<null> becomes C<undef>.

=head1 SEE ALSO

L<JSON::PP>

=head1 LICENSE

Copyright (C) karupanerura.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 AUTHOR

karupanerura E<lt>karupa@cpan.orgE<gt>

=cut



( run in 1.100 second using v1.01-cache-2.11-cpan-39bf76dae61 )