英文:
JSON Array to Java object in Spring Data Elasticsearch getting Null value
问题
我正在使用版本为2.1.0的spring-data-elasticsearch的Java。
除了customList字段外,其他所有字段都正常工作。在Java中,customList始终获取null值。
我的JSON:
{
"Id": "123",
"customList": {
"Item 1": [
{
"name": "xyz",
"price": "15"
},
{
"name": "qwe",
"price": "11"
}
],
"Item 2": [
{
"name": "abc",
"price": "20"
}
]
}
}
我正在尝试在类A中反序列化此JSON:
@Document(indexName = "repository", type = "sop")
public class A {
@Id
private String Id;
@Field(type = FieldType.Nested)
private Map<String, List<B>> customList;
}
public class B {
private String name;
private String price;
}
A的反序列化对象
{
"id": "123",
"customList": null
}
请问是否有人可以解释为什么这个数组没有被反序列化,以及应该如何纠正它。
英文:
I am using Java with spring-data-elasticsearch version 2.1.0
Every field except the customList works fine. customList in java is getting a null value everytime.
My JSON:
{
"Id": "123",
"customList": {
"Item 1": [
{
"name": "xyz",
"price": "15"
},
{
"name": "qwe",
"price": "11"
}
],
"Item 2": [
{
"name": "abc",
"price": "20"
}
]
}
I am trying to deserialize this json in class A:
@Document(indexName = "repository", type = "sop")
public class A {
@Id
private String Id;
@Field(type = FieldType.Nested)
private Map<String, List<B> > customList;
}
public class B {
private string name;
private string price;
}
Deserialized object of A
{
"id": "123",
"List": null
}
Can anyone please give a reason why this array is not deserializing and what can be done to correct it.
专注分享java语言的经验与见解,让所有开发者获益!
评论