add :legacy option (from http://paste.scsys.co.uk/433777)
[p5sagit/JSON-MaybeXS.git] / t / legacy.t
CommitLineData
ebf1e433 1use strict;
2use warnings FATAL => 'all';
3
4use Test::Without::Module 'Cpanel::JSON::XS';
5use Test::More;
6use JSON::MaybeXS qw/:legacy/;
7
8
9
10my $in = '[1, 2, 3, 4]';
11
12
13my $arr = from_json($in);
14my $j = to_json($arr);
15is($j, '[1,2,3,4]');
16is(ref($arr), 'ARRAY');
17
18done_testing;
19
20__END__
21
22 to_json
23 $json_text = to_json($perl_scalar)
24
25 Converts the given Perl data structure to a json string.
26
27 This function call is functionally identical to:
28
29 $json_text = JSON->new->encode($perl_scalar)
30
31 from_json
32 $perl_scalar = from_json($json_text)
33
34 The opposite of "to_json": expects a json string and tries to parse it,
35 returning the resulting reference.
36
37 This function call is functionally identical to:
38
39 $perl_scalar = JSON->decode($json_text)