Android create a JSON array of JSON Objects

后端 未结 4 488
一整个雨季
一整个雨季 2021-01-07 08:46

hi does anyone know how to create a Array that contains objects that in each objects contain several objects? i just can\'t seem to get my head round it

the structur

4条回答
  •  心在旅途
    2021-01-07 09:07

    Do you mean that?:

    JSONObject obj = new JSONObject();
    obj.put("x", "1");
    JSONObject parent_object = new JSONObject();
    parent_object.put("child", obj);
    JSONArray array = new JSONArray(parent_object.toString());
    

提交回复
热议问题