All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.guerlab.spring.commons.jackson.serializer.NumberStringSerializer Maven / Gradle / Ivy

There is a newer version: 2.1.5
Show newest version
package net.guerlab.spring.commons.jackson.serializer;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * 数值类型字符串序列化
 *
 * @author guer
 *
 */
public class NumberStringSerializer extends JsonSerializer {

    @Override
    public void serialize(Number value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        if (value == null) {
            gen.writeNull();
            return;
        }

        gen.writeString(value.toString());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy