{"res":"01","type":"0"}
求指点啊,只会解析列表。。。
直接用JsonObject解析
会解析列表,你不会解析这个?
JSONObject json = new JSONObject(String str);
String res = json.getString("res");
String type = json.getString("type");
直接用fastjson插件中的JSONObject对象进行解析。
1:下载另外一个java的小包就可以了; http://www.JSON.org/java/json_simple.zip
里面有源码和文档例题和编程的lib包;编程只需要json_simple.jar这个包就行;才10几k。
2:在后端java中解析json的代码:
//JavaScript之家:http://www.jrose.cn
a:把json字符串变......
答案就在这里:java解析json
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?
{"res":"01","type":"0"}
String userjson = br.readLine();//获取你传来的 json串,通过IO 流
JSONArray jsonArray = new JSONArray (userjson);
JSONObject jsonObject = jsonArray.getJSONObject(0);
int res = jsonObject.getInt("res");//res = 01
String type= jsonObjetc.getString("type");//type = "0"
用JsonObject解析 可以解决
JSONObject json = new JSONObject(String str);
String res = json.getString("res");
String type = json.getString("type");
JsonObject解析来解析就可以了
[]用JSONArray解析,{}用JSONObject解析,不管多少层只要是{}这个 都用JSONObject解析,实在不会,就用实体类对象解析