Maven
1 | <dependency> |
Object to Json
1 | ObjectMapper mapper = ObjectMapper() |
Json to Object
1 | ObjectMapper mapper = new ObjectMapper(); |
util
1 | object JsonUtil { |
Anotation
@JsonProperty
Error solution
Jackson with JSON: Unrecognized field, not marked as ignorable
1 | true) (ignoreUnknown = |
data class
非Private可以直接生成Json字段,如果添加了Private,则无法生成Json字段,即使添加@JsonProperty也无效。
BigDecimal
必须设置浮点数使用BigDecimal类型
1 | ObjectMapper().enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) |
JsonDeserializer
1 | val mapper = JsonUtil.getMapper() |