I'm getting a response from Elasticsearch in JSON format that I'd like Gson to convert into a Java class, however I'm having trouble wrapping my head about how to develop the class. Here's the JSON that is returned:
{
"took":3,
"_shards":{
"total":3,
"successful":3,
"failed":0
},
"total":1,
"matches":[
{
"_index":"object_percolator",
"_id":"2"
},
{
"_index":"object_percolator",
"_id":"3"
}
]
}
The 'matches' is what is giving me a hard time. How would I design the class to handle that array? Any ideas? Thanks in advance!
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
}
//add the objects you need to be retrieved
Try to google about POJO
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.