1--TEST--
2Test json_decode() function : basic functionality
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7echo "*** Testing json_decode() : basic functionality ***\n";
8
9// array with different values for $string
10$inputs =  array (
11	'0',
12	'123',
13	'-123',
14	'2147483647',
15	'-2147483648',
16	'123.456',
17	'1230',
18	'-1230',
19	'true',
20	'false',
21	'null',
22	'"abc"',
23	'"Hello World\r\n"',
24	'[]',
25	'[1,2,3,4,5]',
26	'{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}',
27	'{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}',
28	'""',
29	'{}'
30);
31
32// loop through with each element of the $inputs array to test json_decode() function
33$count = 1;
34foreach($inputs as $input) {
35	echo "-- Iteration $count --\n";
36	var_dump(json_decode($input));
37	var_dump(json_decode($input, true));
38	$count++;
39}
40
41?>
42===Done===
43--EXPECTF--
44*** Testing json_decode() : basic functionality ***
45-- Iteration 1 --
46int(0)
47int(0)
48-- Iteration 2 --
49int(123)
50int(123)
51-- Iteration 3 --
52int(-123)
53int(-123)
54-- Iteration 4 --
55int(2147483647)
56int(2147483647)
57-- Iteration 5 --
58int(-2147483648)
59int(-2147483648)
60-- Iteration 6 --
61float(123.456)
62float(123.456)
63-- Iteration 7 --
64int(1230)
65int(1230)
66-- Iteration 8 --
67int(-1230)
68int(-1230)
69-- Iteration 9 --
70bool(true)
71bool(true)
72-- Iteration 10 --
73bool(false)
74bool(false)
75-- Iteration 11 --
76NULL
77NULL
78-- Iteration 12 --
79string(3) "abc"
80string(3) "abc"
81-- Iteration 13 --
82string(13) "Hello World
83"
84string(13) "Hello World
85"
86-- Iteration 14 --
87array(0) {
88}
89array(0) {
90}
91-- Iteration 15 --
92array(5) {
93  [0]=>
94  int(1)
95  [1]=>
96  int(2)
97  [2]=>
98  int(3)
99  [3]=>
100  int(4)
101  [4]=>
102  int(5)
103}
104array(5) {
105  [0]=>
106  int(1)
107  [1]=>
108  int(2)
109  [2]=>
110  int(3)
111  [3]=>
112  int(4)
113  [4]=>
114  int(5)
115}
116-- Iteration 16 --
117object(stdClass)#%d (5) {
118  ["myInt"]=>
119  int(99)
120  ["myFloat"]=>
121  float(123.45)
122  ["myNull"]=>
123  NULL
124  ["myBool"]=>
125  bool(true)
126  ["myString"]=>
127  string(11) "Hello World"
128}
129array(5) {
130  ["myInt"]=>
131  int(99)
132  ["myFloat"]=>
133  float(123.45)
134  ["myNull"]=>
135  NULL
136  ["myBool"]=>
137  bool(true)
138  ["myString"]=>
139  string(11) "Hello World"
140}
141-- Iteration 17 --
142object(stdClass)#%d (6) {
143  ["Jan"]=>
144  int(31)
145  ["Feb"]=>
146  int(29)
147  ["Mar"]=>
148  int(31)
149  ["April"]=>
150  int(30)
151  ["May"]=>
152  int(31)
153  ["June"]=>
154  int(30)
155}
156array(6) {
157  ["Jan"]=>
158  int(31)
159  ["Feb"]=>
160  int(29)
161  ["Mar"]=>
162  int(31)
163  ["April"]=>
164  int(30)
165  ["May"]=>
166  int(31)
167  ["June"]=>
168  int(30)
169}
170-- Iteration 18 --
171string(0) ""
172string(0) ""
173-- Iteration 19 --
174object(stdClass)#%d (0) {
175}
176array(0) {
177}
178===Done===
179