问题
I get json response in Buffered Reader. Now How to convert buffered-reader string to JSON?
I get the String like
[
{
"email": "test@gmail.com",
"password": "test@123!",
"role": "monitor",
"code": "0"
}
]
回答1:
JSONArray aardata = new JSONArray(your buffered reader String):
And For Parse
JSONObject obj = arrdata.getJsonObject(0);
String email = obj.getString('email');
回答2:
You can create JSONArray with the response string by using:
JSONArray arrayJSON = new JSONArray(responseString);
And use getJSONObject()
to get JSONObject and use getString()
to get string value from particular JSONObject.
来源:https://stackoverflow.com/questions/21449853/how-to-convert-buffered-reader-string-to-json-in-android