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

io.orchestrate.client.StringToRawJsonSerializer Maven / Gradle / Ivy

package io.orchestrate.client;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;

public class StringToRawJsonSerializer extends JsonSerializer {
    @Override
    public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
        if (value instanceof String) {
            jgen.writeRawValue((String)value);
        } else {
            jgen.writeObject(value);
        }
    }
}