Long類型值過長導致丟失精度變00

前言

Github:https://github.com/HealerJean

博客:http://blog.healerjean.com

類似於LocalDateTime的序列化和反序列化方式

1、修改序列化的方式

1.1、JsonLongSerializer

public class JsonLongSerializer extends JsonSerializer<Long> {
    @Override
    public void serialize(Long aLong, 
                          JsonGenerator jsonGenerator, 
                          SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(Long.toString(aLong));
    }
}

1.2、使用註解

@JsonSerialize(using = JsonLongSerializer.class )
private Long voucherId = null;

ContactAuthor

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章