blob: 4b35d851af4c389c7dabeb72e6f70d91c847d6d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use strict;
use warnings;
use Test::More;
use Data::Dumper::Compact;
my $can_j = eval { require JSON::Dumper::Compact; 1 };
my $circular = {
quux => { bar => 73 },
foo => { baz => [ 42 ] },
};
$circular->{foo}{baz}[1] = $circular->{foo};
is(
Data::Dumper::Compact->dump($circular),
'{ foo => { baz => [ 42, $_->{foo} ] }, quux => { bar => 73 } }'."\n"
);
if ($can_j) {
is(
JSON::Dumper::Compact->dump($circular),
'{
"foo": { "baz": [
42, { "$ref": "#/foo" }
,
] },
"quux": { "bar": 73 },
}
');
}
done_testing;
|