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

com.github.dikhan.utils.JSONObjectSerializer Maven / Gradle / Ivy

There is a newer version: 3.1.2
Show newest version
package com.github.dikhan.utils;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.json.JSONObject;

import java.io.IOException;

public class JSONObjectSerializer extends StdSerializer{
    public JSONObjectSerializer() {
        this(null);
    }

    public JSONObjectSerializer(Class jsonObject) {
        super(jsonObject);
    }

    @Override
    public void serialize(JSONObject jsonObject, JsonGenerator jgen,
                          SerializerProvider provider) throws IOException{
        jgen.writeRawValue(jsonObject.toString());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy