我有这个JSON字符串从第三方API在java中将json字符串转换为JSONArray?
{"msg":"xff","uuid":"44037b67-3629-4325-83e5-7a00cb78dfdf"}
返回当我尝试下面的代码
JSONArray json = new JSONArray(message.toString());
JSONArray arr = json.getJSONArray(0);
String mess = arr.getJSONObject(0).getString("msg");
String uuid = arr.getJSONObject(0).getString("uuid");
System.out.println("message : "+mess);
System.out.println("uuid : "+uuid);
我得到这个下面例外解析它
org.json.JSONException: Value {"msg":"xff","uuid":"44037b67-3629-4325-83e5-7a00cb78dfdf"} of type org.json.JSONObject cannot be converted to JSONArray
什么我可以用其他方式解析它吗?
先了解JSON对象和JSON阵列之间的差异。 – 2015-04-04 10:41:13