【发布时间】:2016-05-19 04:07:26
【问题描述】:
Json 响应:
response :{"status":false,"Message":"Some Database Error"}
- 要求:
我想要键名,即消息而不是消息的值
代码:
private final String KEY_MSG = "Message";
private final String KEY_MSG1 = "message";
try {
AppLog.Log("TAG123", response);
JSONObject jsonObject = new JSONObject(response);
String message1="Message";
if (message1.equals(jsonObject.getString(KEY_MSG)))
{
AppLog.Log("fgesarfefe", "dsfdsfdsfds");
return jsonObject.getString(KEY_MSG);
}
else
{
AppLog.Log("00000000", "111111");
return jsonObject.getString(KEY_MSG1);
}
/* if (jsonObject.getString(KEY_MSG).equals("message"))
{
return jsonObject.getString(KEY_MSG1);
}
else
{*/
// return jsonObject.getString(KEY_MSG);
// }
} catch (JSONException e) {
e.printStackTrace();
}
return "No data";
【问题讨论】:
标签: json parsing android-studio response