Commit | Line | Data |
87d44e90 |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
4 | use JSON::Diffable qw( encode_json decode_json ); |
5 | |
6 | my $data = { |
7 | foo => [23, { bar => 19, baz => undef }, 42], |
8 | bar => { x => undef, y => 17, z => [3..5] }, |
9 | baz => [], |
10 | qux => {}, |
11 | }; |
12 | my $json = encode_json($data); |
13 | |
14 | is "$json\n", <<'ENDJSON', 'encode'; |
15 | { |
16 | "bar": { |
17 | "x": null, |
18 | "y": 17, |
19 | "z": [ |
20 | 3, |
21 | 4, |
22 | 5, |
23 | ], |
24 | }, |
25 | "baz": [ |
26 | ], |
27 | "foo": [ |
28 | 23, |
29 | { |
30 | "bar": 19, |
31 | "baz": null, |
32 | }, |
33 | 42, |
34 | ], |
35 | "qux": { |
36 | }, |
37 | } |
38 | ENDJSON |
39 | |
40 | is_deeply decode_json($json), $data, 'decode'; |
41 | |
42 | done_testing; |