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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
use strict;
use Test::More;
BEGIN { plan tests => 7 };
BEGIN { $ENV{PERL_JSON_BACKEND} ||= 1; }
use JSON -support_by_pp;
SKIP: {
skip "can't use JSON::XS.", 7, unless( JSON->backend->is_xs );
my $json = new JSON;
is($json->indent_length(2)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[1,{"foo":"bar"},"1","/"]|);
is($json->indent->encode([1,{foo => 'bar'}, "1", "/"]), qq|[
1,
{
"foo":"bar"
},
"1",
"/"
]
|);
is($json->escape_slash(1)->pretty->indent_length(2)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[
1,
{
"foo" : "bar"
},
"1",
"\\/"
]
|);
is($json->escape_slash(1)->pretty->indent_length(3)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[
1,
{
"foo" : "bar"
},
"1",
"\\/"
]
|);
is($json->escape_slash(1)->pretty->indent_length(15)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[
1,
{
"foo" : "bar"
},
"1",
"\\/"
]
|);
is($json->indent_length(0)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[
1,
{
"foo" : "bar"
},
"1",
"\\/"
]
|);
is($json->indent(0)->space_before(0)->space_after(0)->escape_slash(0)
->encode([1,{foo => 'bar'}, "1", "/"]), qq|[1,{"foo":"bar"},"1","/"]|);
}
|