php json_decode will return a null answer when it
get ‘\uxxxx’ character since it only supports UTF-8 which was
declared by official website.
So how could we solve this question when we
want to json_decode(Chinese)?
Here provide two way to solve this:
$pp = '{"\u8499\u9a6c\u7279\u9057\u4e66\uff08\u8bd5\u8bfb\uff09": "https://read.douban.com/ebook/256340/", "\u6587\u5b66\u56de\u5fc6\u5f55\uff08\u8bd5\u8bfb\uff09": "https://read.douban.com/ebook/451767/", "\u6587\u5b66\u56de\u5fc6\u5f55\uff1a\u4e2d\u4e16\u7eaa\u2014\u5341\u4e03\u4e16\u7eaa\u4e4b\u5377": "https://read.douban.com/ebook/9837704/", "\u6587\u5b66\u56de\u5fc6\u5f55\uff1a\u53e4\u4ee3\u4e4b\u5377": "https://read.douban.com/ebook/9837472/", "\u6587\u5b66\u56de\u5fc6\u5f55\uff1a\u5341\u516b\u2014\u5341\u4e5d\u4e16\u7eaa\u4e4b\u5377": "https://read.douban.com/ebook/9841737/"}'; echo var_dump(json_decode($pp));
As you can see, we change the
\"
to"
And this is the second way, I love it.
$pp = '{\"\u8499\u9a6c\u7279\u9057\u4e66\uff08\u8bd5\u8bfb\uff09\": \"https://read.douban.com/ebook/256340/\", \"\u6587\u5b66\u56de\u5fc6\u5f55\uff08\u8bd5\u8bfb\uff09\": \"https://read.douban.com/ebook/451767/\", \"\u6587\u5b66\u56de\u5fc6\u5f55\uff1a\u4e2d\u4e16\u7eaa\u2014\u5341\u4e03\u4e16\u7eaa\u4e4b\u5377\": \"https://read.douban.com/ebook/9837704/\", \"\u6587\u5b66\u56de\u5fc6\u5f55\uff1a\u53e4\u4ee3\u4e4b\u5377\": \"https://read.douban.com/ebook/9837472/\", \"\u6587\u5b66\u56de\u5fc6\u5f55\uff1a\u5341\u516b\u2014\u5341\u4e5d\u4e16\u7eaa\u4e4b\u5377\": \"https://read.douban.com/ebook/9841737/\"}';
$python = '"'.$pp.'"';
echo json_decode($python);