![](/img/trans.png)
[英]UnrecognizedPropertyException: Unrecognized field “code” in Android
[英]UnrecognizedPropertyException: Unrecognized field error in android
這是我的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:無法識別的字段“ BrandID”(類com.example.sony.models.Product),未標記為可忽略(9個已知屬性:,“ brandID”,“ subCategoryName” ,“ productID”,“ childItemList”,“ variant”,“ productImagePath”,“ brandName”,“ subCategoryID”,“ productName”])
無法識別的字段“ BrandID”,但該字段在POJO中可用。
我不明白為什么我的Capital Case字段被轉換為Smallcase?
為什么會出現此錯誤? 如何解決?
傑克遜反序列化:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.