This article mainly introduces the json format that cannot be recognized in js after being converted by json_encode. It has a certain reference value. Now I share it with you. Friends in need can refer to it
First of all, let me explain one point. The json format in js uses curly brackets '{}', starting and ending with one character.
But in php, the array with # as the index, after json_encode conversion, is an array with square brackets ' []', a string starting and ending. Therefore, JSON.parse cannot be used to convert data in js.
In order to solve this problem, I thought of many ways, but it felt inconvenient no matter what I did. Finally, I found a relatively simple way.
The above is the detailed content of The php array is converted through json_encode. The json format cannot be recognized in js.. For more information, please follow other related articles on the PHP Chinese website!