Badger::Codec::JSON
use Badger::Codec::JSON; my $codec = Badger::Codec::JSON->new(); my $encoded = $codec->encode({ msg => "Hello World" }); my $decoded = $codec->decode($encoded);
This module implements a subclass of Badger::Codec which uses the JSON::XS or JSON module (whichever you have installed) to encode and decode data to and from JSON. It is little more than an adapter module to fit JSON into the Badger::Codec mould.
Encodes the Perl data in $data
to a JSON string. This method
is a wrapper around the internal the encode_json() subroutine.
$encoded = Badger::Codec::JSON->encode($data);
Decodes the encoded JSON string in $json
back into a Perl
data structure. This method is a wrapper around the internal the decode_json() subroutine.
$decoded = Badger::Codec::JSON->decode($encoded);
This method returns a reference to the real subroutine that's doing all
the encoding work, i.e. the internal encode_json()
subroutine.
Andy Wardley http://wardley.org/