NAME
JSON::PP - An experimental JSON::XS compatible Pure Perl module.
SYNOPSIS
use JSON::PP;
$obj = from_json($json_text);
$json_text = to_json($obj);
# or
$obj = jsonToObj($json_text);
$json_text = objToJson($obj);
$json = new JSON;
$json_text = $json->ascii->pretty($obj);
DESCRIPTION
This module is JSON::XS compatible Pure Perl module. It requires Perl 5.8.
Module variables ($JSON::*) were abolished.
JSON::PP will be renamed JSON (JSON-2.0).
Many things including error handling are learned from JSON::XS. For t/02_error.t compatible, error messages was copied partially from JSON::XS.
FEATURES
perhaps correct unicode handling?
This module knows how to handle Unicode (perhaps), but not yet documents how and when it does so.
round-trip integrity
This module solved the problem pointed out by JSON::XS using B module.
strict checking of JSON correctness
I want to bring close to XS. How do you want to carry out?
slow
Compared to other JSON modules, this module does not compare favourably in terms of speed. Very slowly!
simple to use
This module became very simple. Since its interface were anyway made the same as JSON::XS.
reasonably versatile output formats
See to JSON::XS.
FUNCTIONS
- to_json
-
See to JSON::XS.
objToJson
is an alias. - from_json
-
See to JSON::XS.
jsonToObj
is an alias.
METHODS
- new
-
Returns JSON::PP object.
- ascii
-
See to JSON::XS.
- utf8
-
See to JSON::XS.
- pretty
-
See to JSON::XS.
- indent
-
See to JSON::XS. Strictly, this module does not carry out equivalent to XS.
$json->indent(4);
is not the same as this:
$json->indent();
- space_before
-
See to JSON::XS.
- space_after
-
See JSON::XS.
- canonical
-
See to JSON::XS. Strictly, this module does not carry out equivalent to XS. This method can take a subref for sorting (see to JSON).
- allow_nonref
-
See to JSON::XS.
- shrink
-
Not yet implemented.
- max_depth
-
See to JSON::XS. Strictly, this module does not carry out equivalent to XS.
- encode
-
See to JSON::XS.
- decode
-
See to JSON::XS.
- property
-
Accessor.
$json->property(utf8 => 1); # $json->utf8(1); $value = $json->property('utf8'); # returns 1.
- self_encode
-
See JSON's self convert.
- deny_blessed_object
-
Not yet implemented.
- UTF8_off
-
Not yet implemented.
- allow_tied
-
Enable.
- singlequote
-
Enable.
- barekey
-
Not yet implemented.
- allow_bigint
-
When json text has any integer in decoding more than Perl can't handle, If this option is on, they are converted into Math::BigInt objects.
COMPARISON
Using a benchmark program in the JSON::XS distribution.
module | encode | decode |
-----------|------------|------------|
JSON::PP | 10090.120 | 4621.901 |
-----------|------------|------------|
JSON::XS | 341513.380 | 226138.509 |
-----------+------------+------------+
TODO
- Want to work on Perl 5.6
-
This module uses Encode... I want the unicode handling without Encode when used in perl5.6.
- Document!
-
It is troublesome.
- clean up
-
Under the cleaning.
SEE ALSO
AUTHOR
Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
COPYRIGHT AND LICENSE
Copyright 2007 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.