Example usage for com.fasterxml.jackson.databind.ser.std NonTypedScalarSerializerBase NonTypedScalarSerializerBase

List of usage examples for com.fasterxml.jackson.databind.ser.std NonTypedScalarSerializerBase NonTypedScalarSerializerBase

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.ser.std NonTypedScalarSerializerBase NonTypedScalarSerializerBase.

Prototype

protected NonTypedScalarSerializerBase(Class<T> paramClass) 

Source Link

Usage

From source file:fr.norad.jmxzabbix.core.ZabbixClient.java

public ZabbixClient(ZabbixConfig config) {
    this.config = config;

    // zabbix does not understand boolean with value true without quotes which is default of jackson
    SimpleModule module = new SimpleModule("BooleanAsString", new Version(1, 0, 0, null, null, null));
    module.addSerializer(new NonTypedScalarSerializerBase<Boolean>(Boolean.class) {
        @Override/*from  w w  w. j a v  a 2 s . co  m*/
        public void serialize(Boolean value, JsonGenerator jgen, SerializerProvider provider)
                throws IOException {
            jgen.writeString(value.toString());
        }
    });

    mapper.registerModule(module);
}