in reply to
How to read CPAN documentation
Just use to_json() to go from perl to json, and from_json() to go from json to perl. Here's an example:
use strict;
use JSON;
use Data::Dumper;
# Here's some data
my $data = {
A => 1,
B => "hello world",
D => [
[
'dog',
'cat',
'bird',
],
[ 'red','green','blue'],
],
D => {
X => 1,
Y => 2,
}
};
# print the data
print Dumper($data), "\n";
# convert perl data to json, then print out the json
my $json = to_json($data);
print "$json\n";
# convert the json back to perl, then print it.
# should be the same as before
my $data2 = from_json($json);
print Dumper($data2), "\n";