开发者

How to avoid the comma in json object?

I am writing an applic开发者_如何转开发ation to get the json object from server.

for example:

{"23423423", [abc, 2009-10-12, hello]}  

My problem is: if abc is a string that contains comma, then how can I parse the content in square brackets? normally it should be three items in the square brackets. But if abc contains a comma, then I will get four items, which is not right.

Any ideas ?

Thanks in advance !

EDIT:

JSONObject obj = new JSONObject(); 
List list = new ArrayList(); 
list.add("abc"); 
list.add("2009-10"); 
obj.put("234234", list.toString());// don't use toString();

Finally I solve it, I should not use the list.toString(), otherwise the whole list will be converted to a string.


If abc is a string, then it should be coming from the server quoted, as "abc". If it isn't, then whatever created the JSON is doing it wrong.


A decent JSON parser handles that. Why not just use one of the existing C# JSON parsers out there, such as JSONSharp?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜