0

この JSON を JSONLint で検証し、スクリプトの 25 行目を実行すると、次のようになります。

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

私は得ています:

解析エラー: 構文エラー、C:\Program Files (x86)\Zend\Apache2\htdocs\crosswords\query.blockouts.php25の予期しない 'hintsacross' (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" } ] 
} 

前もって感謝します...

4

1 に答える 1

2

関数に有効な文字列を渡していることを確認してくださいjson_decode

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

文字列を次のように配置します

 $myArray = json_decode('{"k":1}',1); // works
于 2013-08-16T05:19:06.103 に答える