NAME

Data::Object::Json

ABSTRACT

Data-Object Json Class

SYNOPSIS

use Data::Object::Json;

my $json = Data::Object::Json->new;

my $data = $json->from($arg);

DESCRIPTION

Data::Object::Json provides methods for reading and writing JSON data.

METHODS

This package implements the following methods.

dump

dump(HashRef $arg1) : Str

The dump method converts a data structure into a JSON string.

dump example
# given $json

my $string = $json->dump($data);

# '{"foo":...}'

file

file() : Object

The file method returns a Data::Object::Path object for the given file.

file example
# given $json

my $path = $json->file($file);

# ...

from

from(Any $arg1) : Any

The from method calls dump or load based on the give data.

from example
# given $json

my $data = $json->from($string);

# {,...}

my $string = $json->from($data);

# '{"foo":...}'

load

load(Str $arg1) : HashRef

The load method converts a string into a Perl data structure.

load example
# given $json

my $data = $json->load($string);

# {,...}

origin

origin() : Str

The origin method returns the package name of the underlying JSON library used.

origin example
# given $json

my $origin = $json->origin();

# JSON::Tiny

read

read(Str $arg1) : HashRef

The read method reads JSON from the given file and returns a data structure.

read example
# given $json

my $data = $json->read($file);

# {,...}

space

space() : Object

The space method returns a Data::Object::Space object for the origin.

space example
# given $json

my $space = $json->space();

# JSON::Tiny

write

writes(Str $arg1, HashRef $arg2) : Str

The write method writes the given data structure to a file as a JSON string.

write example
# given $json

my $string = $json->write($file, $data);

# ...