Get String from json with nested json object and nested json arrays with multiple json object, in Android

后端 未结 2 883
伪装坚强ぢ
伪装坚强ぢ 2021-02-04 19:10

I need to access as String all the single parameters contained in a complex Json.

for example String people=...; String idPeople=...; etc.

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 19:43

    if we call the json you post myJsonString,

    JSonObject obj = new JSonObject(myJsonString);
    JSonObject result = obj.getJSONObject("result");
    JSonArray people = result.getJSONArray("people");
    int numOfPeople = result.getInt("nPeople");
    

提交回复
热议问题