Article From:https://segmentfault.com/q/1010000012145947
Question:

public function details()
   {
       $goods_info = $this->goodsModel->get_one(26);
       $this->data = $goods_info;
      # sui($goods_info);
       $this->code=1;
       $this->message = 'success';
       $res = ['code'=>$this->code, 'msg'=>$this->message, 'data'=>$this->data];
       echo(json_encode($res,JSON_UNESCAPED_SLASHES));
   }
 "goods_standard": "[{\"item1\":\""Item2\", "price\", "6.6\", "num\", "6.6\", "code\", "remark\", "}, {" item1\ ":" ""," "item2\": "spicy", "price\": "5.6\", "num\": ",", "code\": ",", "remark\", "},"}, {"item1\": ">", ",""Item2\": "spicy", "price\": "6.5\", "num\": ",", "code\": ",", "remark\", "remark\": ""}, {"item1\": "middle part", "it".Em2\ ":", "fragrance", "price\": "6.2\", "num\": ",", "code\": ",", "remark\": "," "}, {" item1\ ":""Price\", "6.2\", "num\", "num\", "code\", "remark\", "}, {" item1\ ":", "", "" item2\ ":"Spicy", "price\": "6.2\", "num\": ",", "code\": ",", "remark\": "" "}, {" item1\ ":" small part "," item2\ ":" Five ".Fragrant "," price\ ":" 5\ "," num\ ":", "," code\ ":", "," remark\ ","}, {"item1\": "," "small", "," item2\ ":" "spicy", ""Price\": "5\", "num\": ",", "code\": ",", "remark\": ""}, {"item1\": "small part", "item2\": "spicy hot", "pric"E\ ":" 5\ "," num\ ":", "," code\ ":", "," remark\ ":" "," ","

thinkphp5 It’s not going to change…

Answer 0:

goods_standard: Which is to take out, such a problem, mainly in the goods_standard field of data, originally JSON format, you use json_encode to change the same, you can run the following code, see whether the data field is or notIt’s like your results

<?php
$data = json_encode(['data'=>'Big ','data1'=>' small ');$arr = ['name'=>'papersnake','age'=>'35','data'=> $data];Echo (json_enCode ($arr));>

There are also two solutions.
1: On the server side, turn goods_standard json_decode to object.
2:You can also directly send such JSON to the client, and the client uses JSON.parse () to convert.

Link of this Article: PHP transfer problem

Leave a Reply

Your email address will not be published. Required fields are marked *