与这个类:
public class Products implements Serializable {
private BigDecimal productId;
private float priority;
public float getPriority() {
return priority;
}
public void setPriority(float priority) {
this.priority = priority;
}
}
在对此类 JSON 数据进行反序列化时:
{"productId":47552,"priority":78}
得到这个错误:
org.codehaus.jackson.map.JsonMappingException:
Can not deserialize instance of float out of FIELD_NAME token
at [Source: org.apache.catalina.connector.CoyoteInputStream@103cf49; line: 1, \
column: 290] (through reference chain: entity.Products["priority"])
但是对于此数据(围绕优先级值的引号)
{"productId":47552,"priority":"78"}
效果很好,所以杰克逊(1.9.9)似乎不尊重数值?我怀疑这里有问题。