Home  >  Article  >  Backend Development  >  json字符串转数组有关问题

json字符串转数组有关问题

WBOY
WBOYOriginal
2016-06-13 12:27:30957browse

json字符串转数组问题
string(186) "{"id":"2","num":2,"store":"9","name":"泰明顿磨损顿报警线(前,后)","price":"88.00"}"
string(96) "{"id":"2","num":1,"store":"9","name":"泰明顿磨损顿报警线(前,后)","price":"88.00"}"

上面2个json字符串, 看着长度是一样的, 打印出来一个186,一个96, 96的这个可以用json_decode转成数组,186那个却不行,求助~~
------解决思路----------------------
后一个长度是 96,是正常的 json 串,所以能解码
前一个长度是 186,显然还包含了其他内容,自然就不能解码了。你可在文本方式下观察 var_dump 的结果

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn