com.github.nmorel.gwtjackson.client.ObjectWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-jackson Show documentation
Show all versions of gwt-jackson Show documentation
gwt-jackson is a GWT JSON serializer/deserializer mechanism based on Jackson annotations
package com.github.nmorel.gwtjackson.client;
import com.github.nmorel.gwtjackson.client.exception.JsonSerializationException;
import com.google.gwt.core.client.GWT;
/**
* Writes an object to JSON.
* To generate an implementation, use {@link GWT#create(Class)}.
* Example :
*
* public class Person {
* public String firstName, lastName;
* public Person(String firstName, String lastName){
* this.firstName = firstName;
* this.lastName = lastName;
* }
* }
*
* public interface PersonWriter extends ObjectWriter<Person> {}
*
* PersonWriter writer = GWT.create(PersonWriter.class);
* String json = writer.write(new Person("Nicolas", "Morel"));
*
* json ==> {"firstName":"Nicolas","lastName":"Morel"}
*
*
* @param Type of the object to write
*
* @author Nicolas Morel
*/
public interface ObjectWriter {
/**
* Writes an object to JSON.
*
* @param value Object to write
*
* @return the JSON output
* @throws JsonSerializationException if an exception occurs while writing the output
*/
String write( T value ) throws JsonSerializationException;
/**
* Writes an object to JSON.
*
* @param value Object to write
* @param ctx Context for the full writing process
*
* @throws JsonSerializationException if an exception occurs while writing the output
*/
String write( T value, JsonSerializationContext ctx ) throws JsonSerializationException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy