Data::Object::Json
Data-Object Json Class
use Data::Object::Json; my $json = Data::Object::Json->new; my $data = $json->from($arg);
Data::Object::Json provides methods for reading and writing JSON data.
This package implements the following methods.
dump(HashRef $arg1) : Str
The dump method converts a data structure into a JSON string.
# given $json my $string = $json->dump($data); # '{"foo":...}'
file() : Object
The file method returns a Data::Object::Path object for the given file.
# given $json my $path = $json->file($file); # ...
from(Any $arg1) : Any
The from method calls dump or load based on the give data.
dump
load
# given $json my $data = $json->from($string); # {,...} my $string = $json->from($data); # '{"foo":...}'
load(Str $arg1) : HashRef
The load method converts a string into a Perl data structure.
# given $json my $data = $json->load($string); # {,...}
origin() : Str
The origin method returns the package name of the underlying JSON library used.
# given $json my $origin = $json->origin(); # JSON::Tiny
read(Str $arg1) : HashRef
The read method reads JSON from the given file and returns a data structure.
# given $json my $data = $json->read($file); # {,...}
space() : Object
The space method returns a Data::Object::Space object for the origin.
origin
# given $json my $space = $json->space(); # JSON::Tiny
writes(Str $arg1, HashRef $arg2) : Str
The write method writes the given data structure to a file as a JSON string.
# given $json my $string = $json->write($file, $data); # ...
To install Data::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Object
CPAN shell
perl -MCPAN -e shell install Data::Object
For more information on module installation, please visit the detailed CPAN module installation guide.