xref: /PHP-5.3/ext/json/tests/002.phpt (revision 8d2a5cab)
1--TEST--
2json_encode() tests
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(json_encode(""));
9var_dump(json_encode(NULL));
10var_dump(json_encode(TRUE));
11
12var_dump(json_encode(array(""=>"")));
13var_dump(json_encode(array(array(1))));
14var_dump(json_encode(array()));
15
16var_dump(json_encode(array(""=>""), JSON_FORCE_OBJECT));
17var_dump(json_encode(array(array(1)), JSON_FORCE_OBJECT));
18var_dump(json_encode(array(), JSON_FORCE_OBJECT));
19
20var_dump(json_encode(1));
21var_dump(json_encode("руссиш"));
22
23
24echo "Done\n";
25?>
26--EXPECTF--
27string(2) """"
28string(4) "null"
29string(4) "true"
30string(7) "{"":""}"
31string(5) "[[1]]"
32string(2) "[]"
33string(7) "{"":""}"
34string(13) "{"0":{"0":1}}"
35string(2) "{}"
36string(1) "1"
37string(38) ""\u0440\u0443\u0441\u0441\u0438\u0448""
38Done
39