繁体   English   中英

Gson.toJson-如何使用类数组设计类

[英]Gson.toJson - How to Design Class with Array of Class

我收到了来自Elasticsearch的JSON格式的响应,我希望Gson转换为Java类,但是我在解决如何开发该类的问题上遇到了麻烦。 这是返回的JSON:

{
"took":3,
"_shards":{
    "total":3,
    "successful":3,
    "failed":0
},
"total":1,
"matches":[
    {
        "_index":"object_percolator",
        "_id":"2"
    },
    {
        "_index":"object_percolator",
        "_id":"3"
    }
]
}

“比赛”让我很难受。 我将如何设计用于处理该数组的类? 有任何想法吗? 提前致谢!

class Matches{
   List<MatchesCollection> matchCollection=new ArrayList<MatchesCollection>();
//add getter and setter here
}
      class MatchesCollection {
             private String _index;
             private Integer _id;
             //add getter and setter here
        }

//添加需要检索的对象

尝试在Google上搜索POJO

检查此链接以创建类 如何创建POJO?

暂无
暂无

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

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