xref: /PHP-8.0/ext/json/tests/001.phpt (revision 32a1ebbd)
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
34NULL
35object(stdClass)#%d (1) {
36  ["test"]=>
37  object(stdClass)#%d (1) {
38    ["foo"]=>
39    string(3) "bar"
40  }
41}
42object(stdClass)#%d (1) {
43  ["test"]=>
44  object(stdClass)#%d (1) {
45    ["foo"]=>
46    string(0) ""
47  }
48}
49object(stdClass)#%d (1) {
50  [""]=>
51  object(stdClass)#%d (1) {
52    ["foo"]=>
53    string(0) ""
54  }
55}
56object(stdClass)#%d (1) {
57  [""]=>
58  object(stdClass)#%d (1) {
59    [""]=>
60    string(0) ""
61  }
62}
63NULL
64NULL
65