xref: /php-src/ext/json/tests/001.phpt (revision b10416a6)
1--TEST--
2json_decode() tests
3--FILE--
4<?php
5
6var_dump(json_decode(""));
7var_dump(json_decode("", 1));
8var_dump(json_decode("", 0));
9var_dump(json_decode(".", 1));
10var_dump(json_decode(".", 0));
11var_dump(json_decode("<?>"));
12var_dump(json_decode(";"));
13var_dump(json_decode("руссиш"));
14var_dump(json_decode("blah"));
15var_dump(json_decode(NULL));
16var_dump(json_decode('{ "test": { "foo": "bar" } }'));
17var_dump(json_decode('{ "test": { "foo": "" } }'));
18var_dump(json_decode('{ "": { "foo": "" } }'));
19var_dump(json_decode('{ "": { "": "" } }'));
20var_dump(json_decode('{ "": { "": "" }'));
21var_dump(json_decode('{ "": "": "" } }'));
22
23?>
24--EXPECTF--
25NULL
26NULL
27NULL
28NULL
29NULL
30NULL
31NULL
32NULL
33NULL
34
35Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in %s on line %d
36NULL
37object(stdClass)#%d (1) {
38  ["test"]=>
39  object(stdClass)#%d (1) {
40    ["foo"]=>
41    string(3) "bar"
42  }
43}
44object(stdClass)#%d (1) {
45  ["test"]=>
46  object(stdClass)#%d (1) {
47    ["foo"]=>
48    string(0) ""
49  }
50}
51object(stdClass)#%d (1) {
52  [""]=>
53  object(stdClass)#%d (1) {
54    ["foo"]=>
55    string(0) ""
56  }
57}
58object(stdClass)#%d (1) {
59  [""]=>
60  object(stdClass)#%d (1) {
61    [""]=>
62    string(0) ""
63  }
64}
65NULL
66NULL
67