更新时间:2022-06-27 05:55:17
您可以使用此JSON 库将您的json字符串解析为JSONObject并从该对象读取值,如下所示:
You may use this JSON library to parse your json string into JSONObject and read value from that object as show below :
JSONObject json = new JSONObject(EntityUtils.toString(entity));
JSONObject sessionObj = json.getJSONObject("session");
System.out.println(sessionObj.getString("name"));
您需要从您想要读取值的位置读取该对象。在这里你想要 name
的参数,它在 session
对象里面,所以你首先得到 session 使用 getJSONObject(KeyString)并使用函数 name 值/javadoc/org/json/JSONObject.html#getString%28java.lang.String%29rel =nofollow> getString(KeyString)如上所示。
You need to read upto that object from where you want to read value. Here you want the value of name
parameter which is inside that session
object, so you first get the value of session
as JSONObject using getJSONObject(KeyString) and read name
value from that object using function getString(KeyString) as show above.
这可以帮到你。