{
"batchcomplete": "",
"warnings": {
"main": {
"*": "Unrecognized parameter: rvprop."
},
"extracts": {
"*": "\"exlimit\" was too large for a whole article extracts request, lowered to 1."
}
},
"query": {
"normalized": [
{
"from": "pune",
"to": "Pune"
}
],
"pages": {
"164634": {
"pageid": 164634,
"ns": 0,
"title": "Pune",
"extract": ""
}
}
}
}
In the above json the numeric key inside "pages" object is dynamic. So how do i make a pojo for this json.
在上面的json中,“pages”对象中的数字键是动态的。那我怎么为这个json做一个pojo。
Please, please, please help me. I've searched a lot for this, but go nothing that works. Also i'm a beginner in retrofit, so please answer in detail. I've seen some answers which mention use of map for such cases (eg. Parse Dynamic Key Json String using Retrofit). But those answers are not elaborated properly. please help me understand it thoroughly.
拜托,拜托,请帮帮我。我为此搜索了很多,但没有任何效果。我也是改装的初学者,所以请详细回答。我已经看到一些答案提到了这种情况下使用map(例如,使用Retrofit解析动态密钥Json字符串)。但这些答案没有得到恰当的阐述。请帮我彻底理解。
1 个解决方案
#1
2
You can use A hashmap
for additional properties/ dynamic properties in your Pages
class
您可以在Pages类中使用A hashmap来获取其他属性/动态属性
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
#1
2
You can use A hashmap
for additional properties/ dynamic properties in your Pages
class
您可以在Pages类中使用A hashmap来获取其他属性/动态属性
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}