com.joseflavio.urucum.json.JSONSerializador Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of urucum Show documentation
Show all versions of urucum Show documentation
Utilitários para desenvolvimento de software em Java.
/*
* Copyright (C) 2016 Jos? Fl?vio de Souza Dias J?nior
*
* This file is part of Urucum - .
*
* Urucum is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Urucum is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Urucum. If not, see .
*/
/*
* Direitos Autorais Reservados (C) 2016 Jos? Fl?vio de Souza Dias J?nior
*
* Este arquivo ? parte de Urucum - .
*
* Urucum ? software livre: voc? pode redistribu?-lo e/ou modific?-lo
* sob os termos da Licen?a P?blica Menos Geral GNU conforme publicada pela
* Free Software Foundation, tanto a vers?o 3 da Licen?a, como
* (a seu crit?rio) qualquer vers?o posterior.
*
* Urucum ? distribu?do na expectativa de que seja ?til,
* por?m, SEM NENHUMA GARANTIA; nem mesmo a garantia impl?cita de
* COMERCIABILIDADE ou ADEQUA??O A UMA FINALIDADE ESPEC?FICA. Consulte a
* Licen?a P?blica Menos Geral do GNU para mais detalhes.
*
* Voc? deve ter recebido uma c?pia da Licen?a P?blica Menos Geral do GNU
* junto com Urucum. Se n?o, veja .
*/
package com.joseflavio.urucum.json;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
/**
* {@link JsonSerializer} de {@link JSON}.
* @author Jos? Fl?vio de Souza Dias J?nior
*/
public class JSONSerializador extends StdSerializer {
private static final long serialVersionUID = 1L;
public JSONSerializador() {
super( JSON.class );
}
public JSONSerializador( Class t ) {
super( t );
}
public JSONSerializador( JavaType type ) {
super( type );
}
public JSONSerializador( StdSerializer src ) {
super( src );
}
public JSONSerializador( Class t, boolean dummy ) {
super( t, dummy );
}
@Override
public void serialize( JSON value, JsonGenerator gen, SerializerProvider provider ) throws IOException {
gen.writeRawValue( value.toString() );
}
@Override
public void serializeWithType( JSON value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer ) throws IOException {
serialize( value, gen, provider );
}
}