我在下面有这个课程:
@JsonAutoDetect
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class AggregationModel {
@JsonProperty(value = "doc_count_error_upper_bound")
private Integer docCountErrorUpperBound;
@JsonProperty(value = "sum_other_doc_count")
private Integer sumOtherDocCount;
@JsonProperty(value = "buckets")
private List<Bucket> buckets;
public Integer getDocCountErrorUpperBound() {
return docCountErrorUpperBound;
}
public void setDocCountErrorUpperBound(Integer docCountErrorUpperBound) {
this.docCountErrorUpperBound = docCountErrorUpperBound;
}
public Integer getSumOtherDocCount() {
return sumOtherDocCount;
}
public void setSumOtherDocCount(Integer sumOtherDocCount) {
this.sumOtherDocCount = sumOtherDocCount;
}
public List<Bucket> getBuckets() {
return buckets;
}
public void setBuckets(List<Bucket> buckets) {
this.buckets = buckets;
}
}
这里是json:
{
"took": 15,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 10,
"max_score": 0,
"hits": []
},
"aggregations": {
"group_by": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 439,
"doc_count": 7,
"average": {
"value": 5
}
}
]
}
}
}
请考虑&#34;聚合&#34;仅部分。
只有桶被正常返回,而其他两个返回为null。我不确定为什么会这样。我使用的是更快的xml.jackson。*(版本2.8.4)。
请帮忙。 TIA。
答案 0 :(得分:0)
我编写的测试用例在后台使用Gson解析JSON,一旦我将其转换为Jackson,它就开始工作了。
非常感谢。