杰克逊试图将json转换为Product class

时间:2015-09-24 16:41:13

标签: java json jackson

我正在尝试转换以下json:

 [
  {
    "title": "1411635467882",
    "price": {
      "value": "1234",
      "currency": "INR"
    }
  }
]

List的对象: https://developers.google.com/resources/api-libraries/documentation/content/v2/java/latest/com/google/api/services/content/model/Product.html

使用代码:

final JavaType type = this.objectMapper.getTypeFactory().constructCollectionType(List.class, Product.class);
return this.objectMapper.readValue(new File(filePath), type);

出现以下错误:

Can not set com.google.api.services.content.model.Price field com.google.api.services.content.model.Product.price to java.util.LinkedHashMap (through reference chain: com.google.api.services.content.model.Product["price"])

如果我用简单的pojo类替换Product和Price类。它工作正常,但它不适用于第三方提供的产品类别: https://developers.google.com/resources/api-libraries/documentation/content/v2/java/latest/com/google/api/services/content/model/Product.html

0 个答案:

没有答案