📄 fail001.phpt
字号:
--TEST--JSON (http://www.crockford.com/JSON/JSON_checker/test/fail*.json)--SKIPIF--<?php if (!extension_loaded('json')) die('skip: json extension not available');?>--FILE--<?php $tests = array('"A JSON payload should be an object or array, not a string."', '["Unclosed array"', '{unquoted_key: "keys must be quoted}', '["extra comma",]', '["double extra comma",,]', '[ , "<-- missing value"]', '["Comma after the close"],', '["Extra close"]]', '{"Extra comma": true,}', '{"Extra value after close": true} "misplaced quoted value"', '{"Illegal expression": 1 + 2}', '{"Illegal invocation": alert()}', '{"Numbers cannot have leading zeroes": 013}', '{"Numbers cannot be hex": 0x14}', '["Illegal backslash escape: \\x15"]', '["Illegal backslash escape: \\\'"]', '["Illegal backslash escape: \\017"]', '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]', '{"Missing colon" null}', '{"Double colon":: null}', '{"Comma instead of colon", null}', '["Colon instead of comma": false]', '["Bad value", truth]', "['single quote']");foreach ($tests as $test){ echo 'Testing: ' . $test . "\n"; echo "AS OBJECT\n"; var_dump(json_decode($test)); echo "AS ARRAY\n"; var_dump(json_decode($test, true));}?>--EXPECT--Testing: "A JSON payload should be an object or array, not a string."AS OBJECTNULLAS ARRAYNULLTesting: ["Unclosed array"AS OBJECTNULLAS ARRAYNULLTesting: {unquoted_key: "keys must be quoted}AS OBJECTNULLAS ARRAYNULLTesting: ["extra comma",]AS OBJECTNULLAS ARRAYNULLTesting: ["double extra comma",,]AS OBJECTNULLAS ARRAYNULLTesting: [ , "<-- missing value"]AS OBJECTNULLAS ARRAYNULLTesting: ["Comma after the close"],AS OBJECTNULLAS ARRAYNULLTesting: ["Extra close"]]AS OBJECTNULLAS ARRAYNULLTesting: {"Extra comma": true,}AS OBJECTNULLAS ARRAYNULLTesting: {"Extra value after close": true} "misplaced quoted value"AS OBJECTNULLAS ARRAYNULLTesting: {"Illegal expression": 1 + 2}AS OBJECTNULLAS ARRAYNULLTesting: {"Illegal invocation": alert()}AS OBJECTNULLAS ARRAYNULLTesting: {"Numbers cannot have leading zeroes": 013}AS OBJECTNULLAS ARRAYNULLTesting: {"Numbers cannot be hex": 0x14}AS OBJECTNULLAS ARRAYNULLTesting: ["Illegal backslash escape: \x15"]AS OBJECTNULLAS ARRAYNULLTesting: ["Illegal backslash escape: \'"]AS OBJECTNULLAS ARRAYNULLTesting: ["Illegal backslash escape: \017"]AS OBJECTNULLAS ARRAYNULLTesting: [[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]AS OBJECTNULLAS ARRAYNULLTesting: {"Missing colon" null}AS OBJECTNULLAS ARRAYNULLTesting: {"Double colon":: null}AS OBJECTNULLAS ARRAYNULLTesting: {"Comma instead of colon", null}AS OBJECTNULLAS ARRAYNULLTesting: ["Colon instead of comma": false]AS OBJECTNULLAS ARRAYNULLTesting: ["Bad value", truth]AS OBJECTNULLAS ARRAYNULLTesting: ['single quote']AS OBJECTNULLAS ARRAYNULL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -