我有REST API-service,它返回带有数百个属性和数组的JSON。我只对将近5个属性和一个数组感兴趣:
{
"name":"butterfree",
"height": 11,
"weight": 320,
"types": [{
"type": {
"name": "flying"
}
}],
"stats": [{
"base_stat": 70,
"effort": 0,
"stat": {
"name": "hp"
}
},
{
"base_stat": 70,
"effort": 0,
"stat": {
"name": "attack"
}
},
{
"base_stat": 70,
"effort": 0,
"stat": {
"name": "defense"
}
}],
"sprites": {
"front_default": "urlToImage"
}
}
我想在GSon和Retrofit库中获取并解析JSON响应,但是我不想为每个JSON对象都创建POJO。因此,我需要您的帮助:如何使GSon仅解析必要的属性和对象?
P.S当前,基于上述JSON,我在http://www.jsonschema2pojo.org/中创建了POJO类。我不确定是否足够