package JSON::XS::VersionOneAndTwo;
use strict;
no strict 'refs';
use warnings;
use JSON::XS;
our $VERSION = '0.31';
sub import {
my ( $exporter, @imports ) = @_;
my ( $caller, $file, $line )
$json_xs_version = $JSON::XS::VERSION;
if ( $json_xs_version < 2.01 ) {
*{ $caller . '::encode_json' } = \&JSON::XS::to_json;
*{ $caller . '::to_json' } = \&JSON::XS::to_json;
. '::decode_json' } = \&JSON::XS::from_json;
*{ $caller . '::from_json' } = \&JSON::XS::from_json;
} else {
*{ $caller . '::encode_json' } = \&JSON::XS::encode_json;
*{
;
use JSON::XS;
my $data = {
'three' => [ 1, 2, 3 ],
'four' => { 'a' => 'b' },
'five' => [ 'a', 'b', 'c' ],
};
my $json = encode_json($data);
cmpthese(
-1,
{ 'encode_json' => s
ub { encode_json($data) },
'decode_json' => sub { decode_json($json) },
}
);
rk qw(cmpthese);
use JSON::XS::VersionOneAndTwo;
my $data = {
'three' => [ 1, 2, 3 ],
'four' => { 'a' => 'b' },
'five' => [ 'a', 'b', 'c' ],
};
my $json = encode_json($data);
cmpthese(
-1,
{ 'encode_json' => sub { encode_json($data) },
'decode_json' => sub { decode_json($json) },
}
);
JSON::XS;
my $data = {
'three' => [ 1, 2, 3 ],
'four' => { 'a' => 'b' },
'five' => [ 'a', 'b', 'c' ],
};
my $json = to_json($data);
cmpthese(
-1,
{ 'to_json' => sub { to_json
($data) },
'from_json' => sub { from_json($json) },
}
);