简体   繁体   English

如何使用不同结构的JSON对象创建POJO类

[英]How to create POJO class with different structure JSON Object

Here is my json schema 这是我的json模式

[
 {
  "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. 如何解决此问题,因为我只是在http://jsonschema2pojo.org中尝试,然后没有结果或没有响应。 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... 好吧,POJO显然必须拥有架构中拥有的所有可能的属性,然后将其他值不设置为null。

So 所以

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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