Array: {code ...} json: {code ...} pics in the array is json, and then json_encode is followed by JSON in js. parse reports the following error: {code ...} array:
Array ([0] => Array ([productid] => 2 [cateid] => 4 [title] => clothing [descr] => [num] => 197 [price] => 888.00 [cover] => 7xpizy.com1.z0.glb.clouddn.com/58087fa893aa7 [pics] => {"58087faa67f8b ": "7xpizy.com1.z0.glb.clouddn.com \/58087faa67f8b"} [issale] => 1 [saleprice] => 799.00 [ishot] => 1 [istui] => 1 [ison] => 1 [createtime] => 0 ))
Json:
[{"productid":"2","cateid":"4","title":"\u8863","descr":"\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416","num":"197","price":"888.00","cover":"7xpizy.com1.z0.glb.clouddn.com\/58087fa893aa7","pics":"{\"58087faa67f8b\":\"7xpizy.com1.z0.glb.clouddn.com\\\/58087faa67f8b\"}","issale":"1","saleprice":"799.00","ishot":"1","istui":"0","ison":"1","createtime":"0"}]
Pics in the array is json, and thenjson_encode
Later in jsJSON.parse
An error is reported:
Unexpected number in JSON at position 169
Reply content:
Array:
Array ([0] => Array ([productid] => 2 [cateid] => 4 [title] => clothing [descr] => [num] => 197 [price] => 888.00 [cover] => 7xpizy.com1.z0.glb.clouddn.com/58087fa893aa7 [pics] => {"58087faa67f8b ": "7xpizy.com1.z0.glb.clouddn.com \/58087faa67f8b"} [issale] => 1 [saleprice] => 799.00 [ishot] => 1 [istui] => 1 [ison] => 1 [createtime] => 0 ))
Json:
[{"productid":"2","cateid":"4","title":"\u8863","descr":"\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416","num":"197","price":"888.00","cover":"7xpizy.com1.z0.glb.clouddn.com\/58087fa893aa7","pics":"{\"58087faa67f8b\":\"7xpizy.com1.z0.glb.clouddn.com\\\/58087faa67f8b\"}","issale":"1","saleprice":"799.00","ishot":"1","istui":"0","ison":"1","createtime":"0"}]
Pics in the array is json, and thenjson_encode
Later in jsJSON.parse
An error is reported:
Unexpected number in JSON at position 169
Process the original array, and convert the json part into an array
$ Arr = Array ("productid" => 2, "cateid" => 4, "title" => "clothing ", "descr" => "", "num" => 197, "price" => 888.00, "cover" => "shield", "pics" => '{"58087faa67f8b": "7xpizy.com1.z0.glb.clouddn.com \/58087faa67f8b"}', "issale" => 1, "saleprice" => 799.00, "ishot" => 1, "istui" => 1, "ison" => 1, "createtime" => 0 )); foreach ($ arr as $ k => $ v) {$ arr [$ k] ['Pics '] = array (json_decode ($ arr [$ k] ['Pics'], true ));} echo json_encode ($ arr );
[{"productid":2,"cateid":4,"title":"\u8863","descr":"\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416\u5416","num":197,"price":888,"cover":"7xpizy.com1.z0.glb.clouddn.com\/58087fa893aa7","pics":[{"58087faa67f8b":"7xpizy.com1.z0.glb.clouddn.com\/58087faa67f8b"}],"issale":1,"saleprice":799,"ishot":1,"istui":1,"ison":1,"createtime":0}]
$ Arr = [['produtid' => 2, 'cateid' => 4, 'title' => 'yie ', 'descal' => ' ', 'num' => 197, 'price' => 888.00, 'cover' => '7xpizy finished, 'pics '=>' {"58087faa67f8b": "Failed \/58087faa67f8b"} ', 'issale' => 1, 'saleprice' => 799.00, 'ishot '=> 1, 'istu' => 1, 'ison' => 1, 'createtime' => 0,]; $ arr [0] ['Pics '] = json_decode ($ arr [0] ['Pics'], true); $ json = json_encode ($ arr ); // The following is the normal output var json = 'of js'
'; Console. log (JSON. parse (json ));