NAME
Haineko::JSON - Wrapper class to load/dump JSON.
DESCRIPTION
Haineko::JSON is a wrapper class for parsing or dumping JSON. As of present, the module is using JSON::Syck module.
SYNOPSIS
use Haineko::JSON;
my $p = { 'name' => 'Haineko', 'age' => 1 };
my $j = Haineko::JSON->dumpjson( $p ); # => is '{"name":"Haineko","age":1}'
my $v = Haineko::JSON->loadjson( $j ); # => is_deeply { 'name' => 'Haineko', 'age' => 1 }
CLASS METHODS
loadfile( File )
loadfile()
is a wrapper method for loading JSON from a file.
my $e = Haineko::JSON->loadfile( '/path/to/haineko.cf' );
warn Dumper $e;
$VAR1 = {
'smtpd' => {
'auth' => 0,
'hostname' => '',
...
},
};
my $f = Haineko::JSON->loadfile( 'does-not-exist.json' ); # undef
loadjson( JSON )
loadjson()
is a wrapper method for loading JSON from scalar value.
my $v = '{ "mikeneko": 1, "kijitora": 2 }'
my $e = Haineko::JSON->loadjson( $v );
warn Dumper $v;
$VAR1 = {
'mikeneko' => 1,
'kijitora' => 2,
};
dumpjson( HashRef|ArrayRef )
dumpjson()
is a wrapper method for dumping JSON from perl data.
my $v = { 'neko' => [ 'kijitora', 'mikeneko' ], 'home' => 'Kyoto' };
my $e = Haineko::JSON->dumpjson( $v );
warn $e; # '{ "neko": [ "kijitora", "mikeneko" ], "home": "Kyoto" }'
REPOSITORY
https://github.com/azumakuniyuki/Haineko
AUTHOR
azumakuniyuki <perl.org [at] azumakuniyuki.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.