简体   繁体   中英

How to create POJO class with different structure JSON Object

Here is my json schema

[
 {
  "title": "Taman Lansia",
  "alamat": "Jl. Cisangkuy, Citarum, Bandung Wetan, Kota Bandung, Jawa Barat 40123",
  "image": "Link image",
  "status": 1
 },
 {
  "title": "Fasilitas Taman_Lansia",
  "fasilitas": [
    {
     "namaFasilitas": "Area Piknik",
     "imageFasilitas": "Link Image"
    },
    {
     "namaFasilitas": "Jalur Jogging",
     "imageFasilitas": "Link Image"
    }
   ],
   "status": 2
 }
]

How to resolve this, because i'm just trying in http://jsonschema2pojo.org and then no result or no response. Thank you

Well you POJO obviously has to have every possible attribute you have in your schema and then just have the other values not set as null...

So

public class MyObject {
    private String title;
    private List<OtherObject> fasilitas;
...

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM