PHP VII: About json_decode json string can not be converted to parse an array of key-value pairs

In php, if a string in a json format of json_decode is through, the key-value pair parsed into json string array type, may acquire a value corresponding to the json array object [ 'key'] by a key.

But there are several points in the process with the need to pay attention.

1. To comply with the string json format, which is a basic requirement.

2. Use the correct usage of key json_decode get an array of objects is json_decode ($ jsonStr, true); true parameter must be added, otherwise the object is an object.

3. To view the complete output json entire resolution, you can not use echo and print, you must use var_dump and print_r.

Apart from meeting 4.json string json format, you have to pay attention to the string inside double quotes - "" instead of single quotes - '', otherwise it will not parse out, this solution can be modified source output, or the replacement of a string treatment double quotes single quotes.

Published 65 original articles · won praise 31 · views 50000 +

Guess you like

Origin blog.csdn.net/zhangtao0417/article/details/96870900