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 {
You can do it with custom serializer, but there is a simpler way to. Enable JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS:
JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS
mapper.getFactory().enable(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS);