OLD | NEW |
| (Empty) |
1 use strict; | |
2 use Test::More; | |
3 BEGIN { plan tests => 7 }; | |
4 | |
5 BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } | |
6 | |
7 use JSON -support_by_pp; | |
8 | |
9 SKIP: { | |
10 skip "can't use JSON::XS.", 7, unless( JSON->backend->is_xs ); | |
11 | |
12 my $json = new JSON; | |
13 | |
14 | |
15 is($json->indent_length(2)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[1,{"foo":"
bar"},"1","/"]|); | |
16 | |
17 is($json->indent->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ | |
18 1, | |
19 { | |
20 "foo":"bar" | |
21 }, | |
22 "1", | |
23 "/" | |
24 ] | |
25 |); | |
26 | |
27 | |
28 is($json->escape_slash(1)->pretty->indent_length(2)->encode([1,{foo => 'bar'}, "
1", "/"]), qq|[ | |
29 1, | |
30 { | |
31 "foo" : "bar" | |
32 }, | |
33 "1", | |
34 "\\/" | |
35 ] | |
36 |); | |
37 | |
38 | |
39 is($json->escape_slash(1)->pretty->indent_length(3)->encode([1,{foo => 'bar'}, "
1", "/"]), qq|[ | |
40 1, | |
41 { | |
42 "foo" : "bar" | |
43 }, | |
44 "1", | |
45 "\\/" | |
46 ] | |
47 |); | |
48 | |
49 is($json->escape_slash(1)->pretty->indent_length(15)->encode([1,{foo => 'bar'},
"1", "/"]), qq|[ | |
50 1, | |
51 { | |
52 "foo" : "bar" | |
53 }, | |
54 "1", | |
55 "\\/" | |
56 ] | |
57 |); | |
58 | |
59 | |
60 is($json->indent_length(0)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ | |
61 1, | |
62 { | |
63 "foo" : "bar" | |
64 }, | |
65 "1", | |
66 "\\/" | |
67 ] | |
68 |); | |
69 | |
70 is($json->indent(0)->space_before(0)->space_after(0)->escape_slash(0) | |
71 ->encode([1,{foo => 'bar'}, "1", "/"]), qq|[1,{"foo":"bar"},"1","/"]|); | |
72 | |
73 | |
74 } | |
75 | |
76 | |
OLD | NEW |