php和js中对json对象及json字符串的转换示例:

[php] 2024-04-25 圈点141

摘要:php和js中对json对象及json字符串的转换示例

php和js中对json对象及json字符串的转换示例:


JS中JSON的处理

JSON对象 ==> String

JSON.stringify(JsonObject);


String ==> JSON对象

JSON.parse(String);


php中JSON的处理

String ==> 数组

json_decode(string,true)


String ==> JSON对象

json_decode(string)


JSON对象 ==> String

json_encode(JSON对象)


json  

感谢反馈,已提交成功,审核后即会显示