带有有效JSON的PHP分析错误


PHP Parse error with valid JSON

我用JSONLint验证了这个JSON,当脚本的第25行运行时,它看起来像:

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

我得到了一个:

分析错误:语法错误,C:''Program Files(x86)''Zend''Apach2''htdocs''crossoords''query.blockouts.php25
中出现意外的"hintscrass"(T_STRING)

拿出剧本。我想知道如何消除这个解析错误。这是JSON:

{
   "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" } ] 
} 

提前感谢。。。

请确保将有效字符串传递给json_decode函数。

 $myArray = json_decode("{"k":1}",1); // wont work as the input json string breaks

并像一样放置字符串

 $myArray = json_decode('{"k":1}',1); // works