【发布时间】:2011-10-18 04:17:16
【问题描述】:
我有这个 JSON 字符串,我想用 json_decode(); 函数对其进行解码
{"phase":2,"id":"pagelet_profile_picture","css":["VCxcl","Ix2pq"],"js":["fZYUE","VfnZ3"],"content":{"pagelet_profile_picture":"\u003cdiv class=\"profile-picture\">\u003cspan class=\"profile-picture-overlay\">\u003c\/span>\u003cimg class=\"photo img\" src\=\"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-snc4\/222_111_2222_n.jpg\" alt=\"bla bla\" id=\"profile_pic\" \/>\u003c\/div>"}}
有json_last_error(); 但它对我没有帮助。 (有时会得到 JSON_ERROR_STATE_MISMATCH 和 JSON_ERROR_SYNTAX)
我想知道这个 JSON 字符串有什么问题,以及如何在 PHP 中自动修复它,以便对其进行解码。 一些代码会很有帮助 谢谢。
【问题讨论】:
-
您的意思是要解码字符串吗?
-
Err...您拥有一个 JSON 字符串,并且想要将其编码为 JSON?编码意味着将对象或数组转换为 JSON。你不能从一个字符串开始,如果你已经有一个 JSON 字符串,那么你可能真的不想这样做。