HttpMessageNotReadableException:无法读取文档:无法反序列化实例

时间:2016-08-22 12:59:02

标签: json web-services rest parsing get

我正在尝试阅读JSON:

[
  {
    "shopkeeper.price/currency": "GBP",
    "shopkeeper.price/location": "GB",
    "shopkeeper.price/sku": "BEAUTY_BRAND|GROUP_1|CHANGED4",
    "shopkeeper.price/stock": 9999,
    "shopkeeper.price/value": 200,
    "shopkeeper.price/wont-ship?": false
  }
]

为:

ShopkeeperProductStockData shopkeeperProductStockData = restTemplate.getForObject(ShopkeeperStockUpdateClient.URL, ShopkeeperProductStockData.class, productCode);

POJO是:

@JsonIgnoreProperties(ignoreUnknown = true)
public class ShopkeeperProductStockData {

    String currency;
    String location;
    String sku;
    Long stock;
    Integer value;

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getSku() { return sku; }

    public void setSku(String sku) { this.sku = sku; }

    public Long getStock() {
        return stock;
    }

    public void setStock(Long stock) {
        this.stock = stock;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

}

我收到错误:

  

org.springframework.http.converter.HttpMessageNotReadableException:   无法读取文档:无法反序列化实例   com.montrose.core.data.ShopkeeperProductStockData出自START_ARRAY   令牌在[来源:java.io.PushbackInputStream@57e80ebc;行:1,   专栏:1];嵌套异常是   com.fasterxml.jackson.databind.JsonMappingException:不能   反序列化的实例   com.montrose.core.data.ShopkeeperProductStockData出自START_ARRAY   令牌在[来源:java.io.PushbackInputStream@57e80ebc;行:1,   专栏:1] at   org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:208)

0 个答案:

没有答案