2013年12月19日星期四

json garbled


List list = new ArrayList();   
list.add("张三");   
list.add("李四");   
JSONArray jsonArray = JSONArray.fromObject(list);   
System.out.println(jsonArray);   
String xmltest=new XMLSerializer().write(jsonArray);   
System.out.println(xmltest);  


------- --------- first print properly
[" Joe Smith ", " John Doe " ]

------- second print garbled ---------

Laos Jizhu Li Yiqi < / a>

------ Solution ------------------------------------ --------
try to write (json, "GBK");
------ For reference only ----------- ----------------------------
your XML encoding problem ...
------ For reference only ---------------------------------------
you call that generates xml the beginning is how the declared ? utf-8? Or GBK? Oh, to be a unified coding .
------ For reference only -------------------------------------- -
agree 3rd floor
------ For reference only ------------------------------- --------



positive solutions
------ For reference only --------------------------------- ------
write (json, "GBK");
been tried, useless , garbled or identical
Another

XMLSerializer not write my own class ah, yes
------ For reference only net.sf.json.xml.XMLSerializer under ----------- ----------------------------
above mistake

write (json, "GBK");

this does not garbled

but I have not mentioned before a request, I asked xml must be
------ For reference only utf-8 of -------------- -------------------------
foreground and background has been encoded . . .
------ For reference only -------------------------------------- -

noon windows console default encoding is gbk, UTF-8 strings had to chaos.
------ For reference only -------------------------------------- -
either transcoding , or Unicode . Only select one
------ For reference only ---------------------------------- -----
your eclipse utf-8 encoding change to the next would not be garbled

look at project properties encoding is not utf-8 to write your business methods

Project - > Properties -> resource -> utf-8 encoding election platform of choice for the appropriate operating system
--- --- For reference only ---------------------------------------

没有评论:

发表评论