PHP json_decode JSON字符串无法解码

Eae*_*Eae 0 php json decode

{ 
    "hintsacross": 
    [ { "number":"1" , "hinttext":"Hurt", "hintsquare":"A1" }, 
      { "number":"5" , "hinttext":"Make a selection", "hintsquare":"A6" }, 
      { "number":"8" , "hinttext":"Frank", "hintsquare":"A10" }
    ] ,
    "hintsdown": 
    [ { "number":"1" , "hinttext":"First Greek letter", "hintsquare":"A1" },
      { "number":"2" , "hinttext":"Used footnotes", "hintsquare":"A2" }, 
      { "number":"3" , "hinttext":"Listened to", "hintsquare":"A3" }
    ] 
 } 
Run Code Online (Sandbox Code Playgroud)

由于某些原因,PHP的json_decode没有解码这个JSON.

提前致谢...

PS我在第25行运行时遇到错误:

$ temp = json_decode($ obj-> hints,true);

解析错误:语法错误,第25行的C:\ Program Files(x86)\ Zend\Apache2\htdocs\crosswords\query.blockouts.php中的意外'hintsacross'(T_STRING)

我通过JSONlint验证了我的JSON,并且出现了解析错误.

Chr*_*nce 5

它是无效的JSON.尝试在"hintsdown"之前添加逗号并重试json_decode.

{
    "hintsacross": [
        {
            "number": "1",
            "hinttext": "Hurt",
            "hintsquare": "A1"
        },
        {
            "number": "5",
            "hinttext": "Make a selection",
            "hintsquare": "A6"
        },
        {
            "number": "8",
            "hinttext": "Frank",
            "hintsquare": "A10"
        }
    ],
    "hintsdown": [
        {
            "number": "1",
            "hinttext": "First Greek letter",
            "hintsquare": "A1"
        },
        {
            "number": "2",
            "hinttext": "Used footnotes",
            "hintsquare": "A2"
        },
        {
            "number": "3",
            "hinttext": "Listened to",
            "hintsquare": "A3"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

  • 顺便说一句,它有助于使用在线工具或其他验证器验证您的JSON(我使用JSONLint) (2认同)