# How to interpreter file into date and json?

I have DateAndJson.txt and want to analyse it.

data = Import["http://home.ustc.edu.cn/~xiaozh/SE/DateAndJson.txt", "List", CharacterEncoding -> "UTF-8"];
date = DateObject /@ data[[;; ;; 2]]
jsondata = data[[2 ;; ;; 2]];


Using this I got error.

ImportString[#, "JSON"] & /@ jsondata


I try to only handle one json object into Mathematica:

Import["http://home.ustc.edu.cn/~xiaozh/SE/SmallJson.txt", "JSON", CharacterEncoding -> "UTF-8"]
(*got the right json but characters display are wrong*)


So how to interpreter the DateAndJson.txt that make it can be analyse in Mathematica?

• You need this ImportString[ Import[LocalAddress, CharacterEncoding -> "CP936"], "RawJSON"] or this ExportString[Import[LocalAddress,CharacterEncoding->"CP936"],"RawJSON"] – yode Dec 23 '16 at 15:16
• @yode: I think the trick is to use "RawJSON" instead of "JSON". The ImportString then also works when Import uses CharacterEncoding -> "UTF-8". I think UTF-8 the prefered encoding for JSON and thus if in doubt makes more sense. I don't see an indication that the data is not UTF-8 encoded but I honestly don't know any of the chinese... – Albert Retey Dec 23 '16 at 21:05
• @yode Thank you! It can works now! – partida Dec 24 '16 at 0:50