如何从MySQL字段中的Json字符串包含双引号错误

时间:2016-08-10 07:45:24

标签: php mysql arrays json utf-8

我在mysql数据库字段

的json字符串中有一些错误
{"videoshow":{"id":"4058517","title":"\u062c\u0634\u0646\u0648\u0627\u0631\u0647 \u0633\u06cc\u0646 - \u0646\u06cc\u0645 \u0646\u06af\u0627\u0647 \u0628\u0647 \u0641\u06cc\u0644\u0645 \u0645\u0631\u06cc\u062e\u06cc (THE MARTIAN)","username":"saros.magazine","userid":"650163","visit_cnt":724,"uid":"26eAX","process":"done","sender_name":"\u06a9\u0627\u0646\u0627\u0644 \u0639\u0644\u0645\u06cc \u0633\u0627\u0631\u0648\u0633","big_poster":"http:\/\/static.asset.aparat.com\/\/avt\/4058517-3577-b__200242495.jpg","small_poster":"http:\/\/static.asset.aparat.com\/\/avt\/4058517-3577__99999.jpg","profilePhoto":"http:\/\/static.aparat.com\/public\/user_data\/profile_photo\/217\/650163-m.jpg?217","duration":"307","sdate":"4 \u0641\u0631\u0648\u0631\u062f\u06cc\u0646 1395","sdate_timediff":12063124,"frame":"http:\/\/www.aparat.com\/\/video\/video\/embed\/videohash\/26eAX\/vt\/frame","video_cnt":"21","official":"no","flv_name":"4cd5c29375ec34e96ffa34c7b01e935f4058517","tags":[{"name":"\u0641\u06cc\u0644\u0645 \u0633\u06cc\u0646\u0645\u0627\u06cc\u06cc","cnt":"1760"},{"name":"\u0633\u0627\u0631\u0648\u0633","cnt":"14"},{"name":"\u062c\u0634\u0646\u0648\u0627\u0631\u0647 \u0641\u06cc\u0644\u0645 \u0633\u06cc\u0646","cnt":"10"}],"tag_str":"\u062c\u0634\u0646\u0648\u0627\u0631\u0647 \u0641\u06cc\u0644\u0645 \u0633\u06cc\u0646-\u0633\u0627\u0631\u0648\u0633-\u0641\u06cc\u0644\u0645 \u0633\u06cc\u0646\u0645\u0627\u06cc\u06cc","description":"\u062f\u0631 \u062f\u0648\u0645\u06cc\u0646 \u0633\u0631\u0649 \u0627\u0632 \u062c\u0634\u0646\u0648\u0627\u0631\u0647 \u0646\u0648\u0631\u0648\u0632\u0649 "\u0633\u06cc\u0646" \u0628\u0647 \u0633\u0631\u0627\u063a \u0641\u06cc\u0644\u0645 \u0632\u06cc\u0628\u0627\u06cc "\u0645\u0631\u06cc\u062e\u06cc" \u0631\u0641\u062a\u0647 \u0627\u06cc\u0645. \u062f\u0631 \u0631\u0648\u0632 \u0627\u0648\u0644 \u0627\u0632 \u0633\u0631\u06cc \u062f\u0648\u0645 \u060c \u0645\u0627\u0646\u0646\u062f \u0633\u0631\u06cc \u0642\u0628\u0644 \u0628\u0627 \u0622\u0642\u0627\u0649 \u062f\u0643\u062a\u0631 \u0646\u0648\u0631\u0648\u0632\u0649 \u0647\u0645\u0631\u0627\u0647 \u0634\u062f\u0647 \u0627\u06cc\u0645. \u0647\u0645 \u0627\u06a9\u0646\u0648\u0646 \u0645\u06cc\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u06cc\u0646 \u0641\u06cc\u0644\u0645 \u0631\u0627 \u0627\u0632 \u0641\u06cc\u0644\u06cc\u0645\u0648 \u0645\u0634\u0627\u0647\u062f\u0647 \u0646\u0645\u0627\u06cc\u06cc\u062f ! \nhttp:\/\/filimo.com\/m\/pa1ny\n\u0628\u0628\u06cc\u0646\u06cc\u062f \u0648 \u0644\u0630\u062a \u0628\u0628\u0631\u06cc\u062f ! \u0633\u06cc\u0646 \u0645\u062b\u0644 \u0633\u06cc\u0646\u0645\u0627 ... \u0633\u06cc\u0646 \u0645\u062b\u0644 \u0633\u0627\u0631\u0648\u0633","cat_id":10,"cat_name":"\u0639\u0644\u0645 \u0648 \u062a\u06a9\u0646\u0648\u0644\u0648\u0698\u06cc","autoplay":false,"video_date_status":"notset","preview":{"type":"video","src":"http:\/\/www.aparat.com\/public\/public\/images\/test\/v1.mp4"},"file_link":"https:\/\/hw14.asset.aparat.com\/aparat-video\/a_6chie7fh4159k7jhn56j18kkf56h9g23j157k6270739-582u__52da4.apt?was=c2VydmVyX3RpbWU9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parat-video\/4cd5c29375ec34e96ffa34c7b01e935f4058517-270p__89545.apt"]},{"profile":"360p","urls":["https:\/\/hw14.asset.aparat.com\/aparat-video\/a_6chie7fh4159k7jhn56j18kkf56h9g23j157k6270739-582u__52da4.apt?was=c2VydmVyX3RpbWU9OC8xMC8yMDE2IDY6Mzg6NDEgQU0maGFzaF92YWx1ZT1OcnNQUzg0Zlo2eE9xTTZ5bVNqOEpBPT0mdmFsaWRtaW51dGVzPTE0NDAwJmlkPWV5SnplWE5mYm1GdFpTSTZJbUZ3WVhKaGRDSXNJblJwYldVaU9qRTBOekE0TVRFeE1qRXNJblpwWkNJNk5EQTFPRFV4Tnl3aWQyRjBZMmhmZEhsd1pTSTZJbVJ2ZDI1c2IyRmtJaXdpZG1semFYUmZjMk52Y0dVaU9qVXNJbkp1WkhWelpYSnBaQ0k2SWpRd05UZzFNVGN4TkRjd09ERXhNVEl4TlRJeU9EYzNJaXdpZFhObGNsOXBjQ0k2SWpRMkxqSXlOUzR5TkRJdU1qSTVJaXdpWkhWeVlYUnBiMjRpT2lJek1EY2lMQ0oxYzJWeWFXUWlPaUkyTlRBeE5qTWlmUT09","http:\/\/as6.asset.aparat.com\/aparat-video\/4cd5c29375ec34e96ffa34c7b01e935f4058517-360p__89545.apt"]}],"videovisit":"http:\/\/www.aparat.com\/etc\/api\/videovisit\/videohash\/26eAX\/utime\/757_1470811121\/hutime\/4fcec5fb6235287a4cc3a0863261384be6f94cc8","videovisitcall_time":5,"hls":{"enable":false,"link":null},"playeradvert":"","playeradvert_src":"http:\/\/aparat.ads.sabavision.com\/showads.php?posid=850&w=100%&h=100%&force_fit=yes&bg=000&ios_ad=yes","playeradvert_time":4,"like":{"status":"no","link":"http:\/\/www.aparat.com\/etc\/api\/videolikeset\/videohash\/26eAX\/code3\/786559717\/luser\/\/ltoken\/\/devicetype\/atrty\/1470811121\/avrvy\/\/\/key\/de73a1ddfcd09ee28dbc181f6262d0c55cfb7d44"},"share":{"status":"login","link":null},"playeradvertcornel":"","has_comment":"yes","has_comment_txt":"","size":"20329949","watch_action":{"type":"watch"},"cost_type":{"type":"free"},"can_download":true,"like_cnt":16,"follow_link":null,"follow_status":null}}
来自json对象字符串的描述项中的

包含双引号,我无法使用PHP json_decode()函数处理它。

我该如何处理这样的jsons字符串?我的json的字符串也有一些utf-8内容

1 个答案:

答案 0 :(得分:0)

在将数据存储到mysql表时,看起来它正在将特殊字符编码为unicode格式。你能否分享一下你用来在mysql中存储这个JSON数据的代码片段?

您在存储时基本上需要正确处理JSON格式,这将简化从表中获取数据的过程。

由于