Android create a JSON array of JSON Objects

后端 未结 4 484
一整个雨季
一整个雨季 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 08:51

    What I would suggest to do is to use JackSON JSON Parser library http://jackson.codehaus.org/ Then you can create a Class with the same fields as the JSON son the mapping from JSON To class will be direct. So once you have all the items from JSON into a List of class you can order by dates or manipulate data as you want. Imagine that src is a String containing the JSON text. With JackSON lib you just need to do this.

    ObjectMapper mapper = new ObjectMapper();

    List result = mapper.readValue(src, new TypeReference>() { });

提交回复
热议问题