这是我的POJO课程。
public class Product implements ParentListItem {
private String ProductName;
private int ProductID;
private String ProductImagePath;
private String BrandName;
private int BrandID;
private String SubCategoryName;
private int SubCategoryID;
private List<ProductVariant> Variants = new ArrayList<>();
Product(){}
}
Json格式:
[{
"Variants": [{
"VariantID": "1",
"VariantName": "50 GM",
"VariantImagePath": null,
"MRP": "19.00",
"SellPrice": "18.24",
"InCart": "0"
}],
"ProductName": "Body Cleanser - Lemon Honey Kanti",
"ProductID": "1",
"BrandName": "Patanjali",
"SubCategoryID": "44",
"SubCategoryName": "Bathing Soap",
"ProductImagePath": "\/images\/patanjali\/1819.png",
"BrandID": "112"
}]
我试图像这样使用这个POJO。
for (DataSnapshot postSnapshot : snapshot.getChildren()) {
Product product = postSnapshot.getValue(Product.class);
products.add(product);
}
但是我收到了这个错误:
引起: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: 无法识别的字段&#34; BrandID&#34; (com.example.sony.models.Product类), 没有标记为可忽略的(9个已知属性:,&#34; brandID&#34;, &#34; subCategoryName&#34;,&#34; productID&#34;,&#34; childItemList&#34;,&#34; variants&#34;, &#34; productImagePath&#34;,&#34; brandName&#34;,&#34; subCategoryID&#34;,&#34; productName&#34;])
无法识别的字段&#34; BrandID&#34; ,但这个字段在POJO中可用。
我不明白为什么我的Capital案例字段会被转换为Smallcase?
为什么会出现这个错误?如何解决这个问题?
答案 0 :(得分:3)
杰克逊反序列化: