NAME

SPVM::JSON - JSON serializing/deserializing

SYNOPSYS

SPVM:

use JSON;

# new
my $json = JSON->new;

# decode
$json->decode($json_text);

# set the canonical flag on
$json->set_canonical(1);

# encode
my $encoded_json = $json->encode($spvm_data);

Perl:

use SPVM 'JSON';

# new
my $json = SPVM::JSON->new;

# decode
$json->decode($json_text);

# set the canonical flag on
$json->set_canonical(1);

# encode
my $encoded_json = $json->encode($spvm_data);

DESCRIPTION

SPVM::JSON converts SPVM data structures to JSON and vice versa.

SPVM::JSON is a SPVM module.

SPVM is yet before 1.0 released. SPVM is changed without warnings. There will be quite a lot of changes.

CLASS METHODS

new

static method new : SPVM::JSON ()

Create new SPVM::JSON object that can be used to de/encode JSON strings.

INSTANCE METHODS

encode

method encode : string ($object : object)

Converts the given SPVM data structure (undef or a object of numeric, string, SPVM::JSON::Bool, SPVM::Hash or SPVM::ObjectList) to its JSON representation.

decode

method decode : object ($json : string)

The opposite of encode: expects a JSON text and tries to parse it, returning the resulting object. Dies on error. Numbers in a JSON text are converted to SPVM::Double.

set_canonical

method set_canonical : void ($enable : byte)

If $enable is true, then the encode method will output JSON objects by sorting their keys. This is adding a comparatively high overhead.

canonical

method canonical : byte ()

Get the canonical flag.