pass001.1.phpt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. --TEST--
  2. JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json)
  3. --INI--
  4. serialize_precision=-1
  5. --FILE--
  6. <?php
  7. /* Modified to test unescaped UNICODE as keys and values.
  8. * Modified to test numbers with exponents without a decimal point.
  9. * Modified to test empty string values.
  10. * Modified to test a mix of integers and strings as keys.
  11. */
  12. $test = "
  13. [
  14. \"JSON Test Pattern pass1\",
  15. {\"object with 1 member\":[\"array with 1 element\"]},
  16. {},
  17. [],
  18. -42,
  19. true,
  20. false,
  21. null,
  22. {
  23. \"integer\": 1234567890,
  24. \"real\": -9876.543210,
  25. \"e\": 0.123456789e-12,
  26. \"E\": 1.234567890E+34,
  27. \"\": 23456789012E666,
  28. \"E no .\": 4E12,
  29. \"zero\": 0,
  30. \"one\": 1,
  31. \"space\": \" \",
  32. \"quote\": \"\\\"\",
  33. \"backslash\": \"\\\\\",
  34. \"controls\": \"\\b\\f\\n\\r\\t\",
  35. \"slash\": \"/ & \\/\",
  36. \"alpha\": \"abcdefghijklmnopqrstuvwyz\",
  37. \"ALPHA\": \"ABCDEFGHIJKLMNOPQRSTUVWYZ\",
  38. \"digit\": \"0123456789\",
  39. \"special\": \"`1~!@#$%^&*()_+-={':[,]}|;.</>?\",
  40. \"hex\": \"\\u0123\\u4567\\u89AB\\uCDEF\\uabcd\\uef4A\",
  41. \"unicode\": \"\\u30d7\\u30ec\\u30b9\\u30ad\\u30c3\\u30c8\",
  42. \"プレスキット\": \"プレスキット\",
  43. \"empty_string\": \"\",
  44. \"true\": true,
  45. \"false\": false,
  46. \"null\": null,
  47. \"array\":[ ],
  48. \"object\":{ },
  49. \"123\":{\"456\":{\"abc\":{\"789\":\"def\",\"012\":[1,2,\"5\",500],\"ghi\":[1,2,\"five\",50,\"sixty\"]}}},
  50. \"address\": \"50 St. James Street\",
  51. \"url\": \"http://www.JSON.org/\",
  52. \"comment\": \"// /* <!-- --\",
  53. \"# -- --> */\": \" \",
  54. \" s p a c e d \" :[1,2 , 3
  55. ,
  56. 4 , 5 , 6 ,7 ],
  57. \"compact\": [1,2,3,4,5,6,7],
  58. \"jsontext\": \"{\\\"object with 1 member\\\":[\\\"array with 1 element\\\"]}\",
  59. \"quotes\": \"&#34; \\u0022 %22 0x22 034 &#x22;\",
  60. \"\\/\\\\\\\"\\uCAFE\\uBABE\\uAB98\\uFCDE\\ubcda\\uef4A\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?\"
  61. : \"A key can be any string\"
  62. },
  63. 0.5 ,98.6
  64. ,
  65. 99.44
  66. ,
  67. 1066
  68. ,\"rosebud\"]
  69. ";
  70. echo 'Testing:' . $test . "\n";
  71. echo "DECODE: AS OBJECT\n";
  72. $obj = json_decode($test);
  73. var_dump($obj);
  74. echo "DECODE: AS ARRAY\n";
  75. $arr = json_decode($test, true);
  76. var_dump($arr);
  77. echo "ENCODE: FROM OBJECT\n";
  78. $obj_enc = json_encode($obj, JSON_PARTIAL_OUTPUT_ON_ERROR);
  79. echo $obj_enc . "\n";
  80. echo "ENCODE: FROM ARRAY\n";
  81. $arr_enc = json_encode($arr, JSON_PARTIAL_OUTPUT_ON_ERROR);
  82. echo $arr_enc . "\n";
  83. echo "DECODE AGAIN: AS OBJECT\n";
  84. $obj = json_decode($obj_enc);
  85. var_dump($obj);
  86. echo "DECODE AGAIN: AS ARRAY\n";
  87. $arr = json_decode($arr_enc, true);
  88. var_dump($arr);
  89. ?>
  90. --EXPECTF--
  91. Testing:
  92. [
  93. "JSON Test Pattern pass1",
  94. {"object with 1 member":["array with 1 element"]},
  95. {},
  96. [],
  97. -42,
  98. true,
  99. false,
  100. null,
  101. {
  102. "integer": 1234567890,
  103. "real": -9876.543210,
  104. "e": 0.123456789e-12,
  105. "E": 1.234567890E+34,
  106. "": 23456789012E666,
  107. "E no .": 4E12,
  108. "zero": 0,
  109. "one": 1,
  110. "space": " ",
  111. "quote": "\"",
  112. "backslash": "\\",
  113. "controls": "\b\f\n\r\t",
  114. "slash": "/ & \/",
  115. "alpha": "abcdefghijklmnopqrstuvwyz",
  116. "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
  117. "digit": "0123456789",
  118. "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
  119. "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
  120. "unicode": "\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8",
  121. "プレスキット": "プレスキット",
  122. "empty_string": "",
  123. "true": true,
  124. "false": false,
  125. "null": null,
  126. "array":[ ],
  127. "object":{ },
  128. "123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},
  129. "address": "50 St. James Street",
  130. "url": "http://www.JSON.org/",
  131. "comment": "// /* <!-- --",
  132. "# -- --> */": " ",
  133. " s p a c e d " :[1,2 , 3
  134. ,
  135. 4 , 5 , 6 ,7 ],
  136. "compact": [1,2,3,4,5,6,7],
  137. "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
  138. "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
  139. "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
  140. : "A key can be any string"
  141. },
  142. 0.5 ,98.6
  143. ,
  144. 99.44
  145. ,
  146. 1066
  147. ,"rosebud"]
  148. DECODE: AS OBJECT
  149. array(14) {
  150. [0]=>
  151. string(23) "JSON Test Pattern pass1"
  152. [1]=>
  153. object(stdClass)#%d (1) {
  154. ["object with 1 member"]=>
  155. array(1) {
  156. [0]=>
  157. string(20) "array with 1 element"
  158. }
  159. }
  160. [2]=>
  161. object(stdClass)#%d (0) {
  162. }
  163. [3]=>
  164. array(0) {
  165. }
  166. [4]=>
  167. int(-42)
  168. [5]=>
  169. bool(true)
  170. [6]=>
  171. bool(false)
  172. [7]=>
  173. NULL
  174. [8]=>
  175. object(stdClass)#%d (36) {
  176. ["integer"]=>
  177. int(1234567890)
  178. ["real"]=>
  179. float(-9876.54321)
  180. ["e"]=>
  181. float(1.23456789E-13)
  182. ["E"]=>
  183. float(1.23456789E+34)
  184. [""]=>
  185. float(INF)
  186. ["E no ."]=>
  187. float(4000000000000)
  188. ["zero"]=>
  189. int(0)
  190. ["one"]=>
  191. int(1)
  192. ["space"]=>
  193. string(1) " "
  194. ["quote"]=>
  195. string(1) """
  196. ["backslash"]=>
  197. string(1) "\"
  198. ["controls"]=>
  199. string(5) "
  200. "
  201. ["slash"]=>
  202. string(5) "/ & /"
  203. ["alpha"]=>
  204. string(25) "abcdefghijklmnopqrstuvwyz"
  205. ["ALPHA"]=>
  206. string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
  207. ["digit"]=>
  208. string(10) "0123456789"
  209. ["special"]=>
  210. string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
  211. ["hex"]=>
  212. string(17) "ģ䕧覫췯ꯍ"
  213. ["unicode"]=>
  214. string(18) "プレスキット"
  215. ["プレスキット"]=>
  216. string(18) "プレスキット"
  217. ["empty_string"]=>
  218. string(0) ""
  219. ["true"]=>
  220. bool(true)
  221. ["false"]=>
  222. bool(false)
  223. ["null"]=>
  224. NULL
  225. ["array"]=>
  226. array(0) {
  227. }
  228. ["object"]=>
  229. object(stdClass)#%d (0) {
  230. }
  231. ["123"]=>
  232. object(stdClass)#%d (1) {
  233. ["456"]=>
  234. object(stdClass)#%d (1) {
  235. ["abc"]=>
  236. object(stdClass)#%d (3) {
  237. ["789"]=>
  238. string(3) "def"
  239. ["012"]=>
  240. array(4) {
  241. [0]=>
  242. int(1)
  243. [1]=>
  244. int(2)
  245. [2]=>
  246. string(1) "5"
  247. [3]=>
  248. int(500)
  249. }
  250. ["ghi"]=>
  251. array(5) {
  252. [0]=>
  253. int(1)
  254. [1]=>
  255. int(2)
  256. [2]=>
  257. string(4) "five"
  258. [3]=>
  259. int(50)
  260. [4]=>
  261. string(5) "sixty"
  262. }
  263. }
  264. }
  265. }
  266. ["address"]=>
  267. string(19) "50 St. James Street"
  268. ["url"]=>
  269. string(20) "http://www.JSON.org/"
  270. ["comment"]=>
  271. string(13) "// /* <!-- --"
  272. ["# -- --> */"]=>
  273. string(1) " "
  274. [" s p a c e d "]=>
  275. array(7) {
  276. [0]=>
  277. int(1)
  278. [1]=>
  279. int(2)
  280. [2]=>
  281. int(3)
  282. [3]=>
  283. int(4)
  284. [4]=>
  285. int(5)
  286. [5]=>
  287. int(6)
  288. [6]=>
  289. int(7)
  290. }
  291. ["compact"]=>
  292. array(7) {
  293. [0]=>
  294. int(1)
  295. [1]=>
  296. int(2)
  297. [2]=>
  298. int(3)
  299. [3]=>
  300. int(4)
  301. [4]=>
  302. int(5)
  303. [5]=>
  304. int(6)
  305. [6]=>
  306. int(7)
  307. }
  308. ["jsontext"]=>
  309. string(49) "{"object with 1 member":["array with 1 element"]}"
  310. ["quotes"]=>
  311. string(27) "&#34; " %22 0x22 034 &#x22;"
  312. ["/\"쫾몾ꮘﳞ볚
  313. `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
  314. string(23) "A key can be any string"
  315. }
  316. [9]=>
  317. float(0.5)
  318. [10]=>
  319. float(98.6)
  320. [11]=>
  321. float(99.44)
  322. [12]=>
  323. int(1066)
  324. [13]=>
  325. string(7) "rosebud"
  326. }
  327. DECODE: AS ARRAY
  328. array(14) {
  329. [0]=>
  330. string(23) "JSON Test Pattern pass1"
  331. [1]=>
  332. array(1) {
  333. ["object with 1 member"]=>
  334. array(1) {
  335. [0]=>
  336. string(20) "array with 1 element"
  337. }
  338. }
  339. [2]=>
  340. array(0) {
  341. }
  342. [3]=>
  343. array(0) {
  344. }
  345. [4]=>
  346. int(-42)
  347. [5]=>
  348. bool(true)
  349. [6]=>
  350. bool(false)
  351. [7]=>
  352. NULL
  353. [8]=>
  354. array(36) {
  355. ["integer"]=>
  356. int(1234567890)
  357. ["real"]=>
  358. float(-9876.54321)
  359. ["e"]=>
  360. float(1.23456789E-13)
  361. ["E"]=>
  362. float(1.23456789E+34)
  363. [""]=>
  364. float(INF)
  365. ["E no ."]=>
  366. float(4000000000000)
  367. ["zero"]=>
  368. int(0)
  369. ["one"]=>
  370. int(1)
  371. ["space"]=>
  372. string(1) " "
  373. ["quote"]=>
  374. string(1) """
  375. ["backslash"]=>
  376. string(1) "\"
  377. ["controls"]=>
  378. string(5) "
  379. "
  380. ["slash"]=>
  381. string(5) "/ & /"
  382. ["alpha"]=>
  383. string(25) "abcdefghijklmnopqrstuvwyz"
  384. ["ALPHA"]=>
  385. string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
  386. ["digit"]=>
  387. string(10) "0123456789"
  388. ["special"]=>
  389. string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
  390. ["hex"]=>
  391. string(17) "ģ䕧覫췯ꯍ"
  392. ["unicode"]=>
  393. string(18) "プレスキット"
  394. ["プレスキット"]=>
  395. string(18) "プレスキット"
  396. ["empty_string"]=>
  397. string(0) ""
  398. ["true"]=>
  399. bool(true)
  400. ["false"]=>
  401. bool(false)
  402. ["null"]=>
  403. NULL
  404. ["array"]=>
  405. array(0) {
  406. }
  407. ["object"]=>
  408. array(0) {
  409. }
  410. [123]=>
  411. array(1) {
  412. [456]=>
  413. array(1) {
  414. ["abc"]=>
  415. array(3) {
  416. [789]=>
  417. string(3) "def"
  418. ["012"]=>
  419. array(4) {
  420. [0]=>
  421. int(1)
  422. [1]=>
  423. int(2)
  424. [2]=>
  425. string(1) "5"
  426. [3]=>
  427. int(500)
  428. }
  429. ["ghi"]=>
  430. array(5) {
  431. [0]=>
  432. int(1)
  433. [1]=>
  434. int(2)
  435. [2]=>
  436. string(4) "five"
  437. [3]=>
  438. int(50)
  439. [4]=>
  440. string(5) "sixty"
  441. }
  442. }
  443. }
  444. }
  445. ["address"]=>
  446. string(19) "50 St. James Street"
  447. ["url"]=>
  448. string(20) "http://www.JSON.org/"
  449. ["comment"]=>
  450. string(13) "// /* <!-- --"
  451. ["# -- --> */"]=>
  452. string(1) " "
  453. [" s p a c e d "]=>
  454. array(7) {
  455. [0]=>
  456. int(1)
  457. [1]=>
  458. int(2)
  459. [2]=>
  460. int(3)
  461. [3]=>
  462. int(4)
  463. [4]=>
  464. int(5)
  465. [5]=>
  466. int(6)
  467. [6]=>
  468. int(7)
  469. }
  470. ["compact"]=>
  471. array(7) {
  472. [0]=>
  473. int(1)
  474. [1]=>
  475. int(2)
  476. [2]=>
  477. int(3)
  478. [3]=>
  479. int(4)
  480. [4]=>
  481. int(5)
  482. [5]=>
  483. int(6)
  484. [6]=>
  485. int(7)
  486. }
  487. ["jsontext"]=>
  488. string(49) "{"object with 1 member":["array with 1 element"]}"
  489. ["quotes"]=>
  490. string(27) "&#34; " %22 0x22 034 &#x22;"
  491. ["/\"쫾몾ꮘﳞ볚
  492. `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
  493. string(23) "A key can be any string"
  494. }
  495. [9]=>
  496. float(0.5)
  497. [10]=>
  498. float(98.6)
  499. [11]=>
  500. float(99.44)
  501. [12]=>
  502. int(1066)
  503. [13]=>
  504. string(7) "rosebud"
  505. }
  506. ENCODE: FROM OBJECT
  507. ["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"":0,"E no .":4000000000000,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":{},"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
  508. ENCODE: FROM ARRAY
  509. ["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"":0,"E no .":4000000000000,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":[],"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
  510. DECODE AGAIN: AS OBJECT
  511. array(14) {
  512. [0]=>
  513. string(23) "JSON Test Pattern pass1"
  514. [1]=>
  515. object(stdClass)#%d (1) {
  516. ["object with 1 member"]=>
  517. array(1) {
  518. [0]=>
  519. string(20) "array with 1 element"
  520. }
  521. }
  522. [2]=>
  523. object(stdClass)#%d (0) {
  524. }
  525. [3]=>
  526. array(0) {
  527. }
  528. [4]=>
  529. int(-42)
  530. [5]=>
  531. bool(true)
  532. [6]=>
  533. bool(false)
  534. [7]=>
  535. NULL
  536. [8]=>
  537. object(stdClass)#%d (36) {
  538. ["integer"]=>
  539. int(1234567890)
  540. ["real"]=>
  541. float(-9876.54321)
  542. ["e"]=>
  543. float(1.23456789E-13)
  544. ["E"]=>
  545. float(1.23456789E+34)
  546. [""]=>
  547. int(0)
  548. ["E no ."]=>
  549. %s(4000000000000)
  550. ["zero"]=>
  551. int(0)
  552. ["one"]=>
  553. int(1)
  554. ["space"]=>
  555. string(1) " "
  556. ["quote"]=>
  557. string(1) """
  558. ["backslash"]=>
  559. string(1) "\"
  560. ["controls"]=>
  561. string(5) "
  562. "
  563. ["slash"]=>
  564. string(5) "/ & /"
  565. ["alpha"]=>
  566. string(25) "abcdefghijklmnopqrstuvwyz"
  567. ["ALPHA"]=>
  568. string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
  569. ["digit"]=>
  570. string(10) "0123456789"
  571. ["special"]=>
  572. string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
  573. ["hex"]=>
  574. string(17) "ģ䕧覫췯ꯍ"
  575. ["unicode"]=>
  576. string(18) "プレスキット"
  577. ["プレスキット"]=>
  578. string(18) "プレスキット"
  579. ["empty_string"]=>
  580. string(0) ""
  581. ["true"]=>
  582. bool(true)
  583. ["false"]=>
  584. bool(false)
  585. ["null"]=>
  586. NULL
  587. ["array"]=>
  588. array(0) {
  589. }
  590. ["object"]=>
  591. object(stdClass)#%d (0) {
  592. }
  593. ["123"]=>
  594. object(stdClass)#%d (1) {
  595. ["456"]=>
  596. object(stdClass)#%d (1) {
  597. ["abc"]=>
  598. object(stdClass)#%d (3) {
  599. ["789"]=>
  600. string(3) "def"
  601. ["012"]=>
  602. array(4) {
  603. [0]=>
  604. int(1)
  605. [1]=>
  606. int(2)
  607. [2]=>
  608. string(1) "5"
  609. [3]=>
  610. int(500)
  611. }
  612. ["ghi"]=>
  613. array(5) {
  614. [0]=>
  615. int(1)
  616. [1]=>
  617. int(2)
  618. [2]=>
  619. string(4) "five"
  620. [3]=>
  621. int(50)
  622. [4]=>
  623. string(5) "sixty"
  624. }
  625. }
  626. }
  627. }
  628. ["address"]=>
  629. string(19) "50 St. James Street"
  630. ["url"]=>
  631. string(20) "http://www.JSON.org/"
  632. ["comment"]=>
  633. string(13) "// /* <!-- --"
  634. ["# -- --> */"]=>
  635. string(1) " "
  636. [" s p a c e d "]=>
  637. array(7) {
  638. [0]=>
  639. int(1)
  640. [1]=>
  641. int(2)
  642. [2]=>
  643. int(3)
  644. [3]=>
  645. int(4)
  646. [4]=>
  647. int(5)
  648. [5]=>
  649. int(6)
  650. [6]=>
  651. int(7)
  652. }
  653. ["compact"]=>
  654. array(7) {
  655. [0]=>
  656. int(1)
  657. [1]=>
  658. int(2)
  659. [2]=>
  660. int(3)
  661. [3]=>
  662. int(4)
  663. [4]=>
  664. int(5)
  665. [5]=>
  666. int(6)
  667. [6]=>
  668. int(7)
  669. }
  670. ["jsontext"]=>
  671. string(49) "{"object with 1 member":["array with 1 element"]}"
  672. ["quotes"]=>
  673. string(27) "&#34; " %22 0x22 034 &#x22;"
  674. ["/\"쫾몾ꮘﳞ볚
  675. `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
  676. string(23) "A key can be any string"
  677. }
  678. [9]=>
  679. float(0.5)
  680. [10]=>
  681. float(98.6)
  682. [11]=>
  683. float(99.44)
  684. [12]=>
  685. int(1066)
  686. [13]=>
  687. string(7) "rosebud"
  688. }
  689. DECODE AGAIN: AS ARRAY
  690. array(14) {
  691. [0]=>
  692. string(23) "JSON Test Pattern pass1"
  693. [1]=>
  694. array(1) {
  695. ["object with 1 member"]=>
  696. array(1) {
  697. [0]=>
  698. string(20) "array with 1 element"
  699. }
  700. }
  701. [2]=>
  702. array(0) {
  703. }
  704. [3]=>
  705. array(0) {
  706. }
  707. [4]=>
  708. int(-42)
  709. [5]=>
  710. bool(true)
  711. [6]=>
  712. bool(false)
  713. [7]=>
  714. NULL
  715. [8]=>
  716. array(36) {
  717. ["integer"]=>
  718. int(1234567890)
  719. ["real"]=>
  720. float(-9876.54321)
  721. ["e"]=>
  722. float(1.23456789E-13)
  723. ["E"]=>
  724. float(1.23456789E+34)
  725. [""]=>
  726. int(0)
  727. ["E no ."]=>
  728. %s(4000000000000)
  729. ["zero"]=>
  730. int(0)
  731. ["one"]=>
  732. int(1)
  733. ["space"]=>
  734. string(1) " "
  735. ["quote"]=>
  736. string(1) """
  737. ["backslash"]=>
  738. string(1) "\"
  739. ["controls"]=>
  740. string(5) "
  741. "
  742. ["slash"]=>
  743. string(5) "/ & /"
  744. ["alpha"]=>
  745. string(25) "abcdefghijklmnopqrstuvwyz"
  746. ["ALPHA"]=>
  747. string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
  748. ["digit"]=>
  749. string(10) "0123456789"
  750. ["special"]=>
  751. string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
  752. ["hex"]=>
  753. string(17) "ģ䕧覫췯ꯍ"
  754. ["unicode"]=>
  755. string(18) "プレスキット"
  756. ["プレスキット"]=>
  757. string(18) "プレスキット"
  758. ["empty_string"]=>
  759. string(0) ""
  760. ["true"]=>
  761. bool(true)
  762. ["false"]=>
  763. bool(false)
  764. ["null"]=>
  765. NULL
  766. ["array"]=>
  767. array(0) {
  768. }
  769. ["object"]=>
  770. array(0) {
  771. }
  772. [123]=>
  773. array(1) {
  774. [456]=>
  775. array(1) {
  776. ["abc"]=>
  777. array(3) {
  778. [789]=>
  779. string(3) "def"
  780. ["012"]=>
  781. array(4) {
  782. [0]=>
  783. int(1)
  784. [1]=>
  785. int(2)
  786. [2]=>
  787. string(1) "5"
  788. [3]=>
  789. int(500)
  790. }
  791. ["ghi"]=>
  792. array(5) {
  793. [0]=>
  794. int(1)
  795. [1]=>
  796. int(2)
  797. [2]=>
  798. string(4) "five"
  799. [3]=>
  800. int(50)
  801. [4]=>
  802. string(5) "sixty"
  803. }
  804. }
  805. }
  806. }
  807. ["address"]=>
  808. string(19) "50 St. James Street"
  809. ["url"]=>
  810. string(20) "http://www.JSON.org/"
  811. ["comment"]=>
  812. string(13) "// /* <!-- --"
  813. ["# -- --> */"]=>
  814. string(1) " "
  815. [" s p a c e d "]=>
  816. array(7) {
  817. [0]=>
  818. int(1)
  819. [1]=>
  820. int(2)
  821. [2]=>
  822. int(3)
  823. [3]=>
  824. int(4)
  825. [4]=>
  826. int(5)
  827. [5]=>
  828. int(6)
  829. [6]=>
  830. int(7)
  831. }
  832. ["compact"]=>
  833. array(7) {
  834. [0]=>
  835. int(1)
  836. [1]=>
  837. int(2)
  838. [2]=>
  839. int(3)
  840. [3]=>
  841. int(4)
  842. [4]=>
  843. int(5)
  844. [5]=>
  845. int(6)
  846. [6]=>
  847. int(7)
  848. }
  849. ["jsontext"]=>
  850. string(49) "{"object with 1 member":["array with 1 element"]}"
  851. ["quotes"]=>
  852. string(27) "&#34; " %22 0x22 034 &#x22;"
  853. ["/\"쫾몾ꮘﳞ볚
  854. `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
  855. string(23) "A key can be any string"
  856. }
  857. [9]=>
  858. float(0.5)
  859. [10]=>
  860. float(98.6)
  861. [11]=>
  862. float(99.44)
  863. [12]=>
  864. int(1066)
  865. [13]=>
  866. string(7) "rosebud"
  867. }