请求后出现以下JSON字符串。无论我尝试什么,我都无法解析数据。
[{
"_id": {
"$oid": "5909846cbd966f2d371bc624"
},
"member_id": "NTkwOTEyNzdiZDk2NmYyZDM3MTkyY2M1",
"sensor_name": "Temprature",
"value": "27.28",
"date": "2017-05-03 10:19:07"
}]
答案 0 :(得分:0)
尝试使用以下代码:
try {
JSONArray jsonArray = new JSONArray(response);
JSONObject jsonObject = jsonArray.get(0);
JSONObject _id = jsonObject.getJSONObject("_id");
String old = _id.getString("$oid");
String member_id = jsonObject.getString("member_id");
String sensor_name = jsonObject.getString("sensor_name");
String value = jsonObject.getString("value");
String date = jsonObject.getString("date");
}catch(JSONException e){
}