Jackson serializer for primitive types

后端 未结 2 434
鱼传尺愫
鱼传尺愫 2020-12-20 01:01

I am writing a custom serializer to convert double values into strings in JSON objects. My code so far:

public String toJson(Object obj) throws IOException {         


        
2条回答
  •  攒了一身酷
    2020-12-20 01:32

    You can register the JsonSerializer for the primitive type double.

    module.addSerializer(double.class, new DoubleSerializer());
    

提交回复
热议问题