Package org.dominokit.jacksonapt
Interface ObjectWriter<T>
- Type Parameters:
T- Type of the object to write
- All Known Subinterfaces:
ObjectMapper<T>
- All Known Implementing Classes:
AbstractObjectMapper,AbstractObjectReader,AbstractObjectWriter
public interface ObjectWriter<T>
Writes an object to JSON.
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 = new PersonWriterImpl();
String json = writer.write(new Person("Nicolas", "Morel"));
json ==> {"firstName":"Nicolas","lastName":"Morel"}
- Version:
- $Id: $
- Author:
- Nicolas Morel
-
Method Summary
Modifier and Type Method Description JsonSerializer<T>getSerializer()getSerializer.java.lang.Stringwrite(T value)Writes an object to JSON.java.lang.Stringwrite(T value, JsonSerializationContext ctx)Writes an object to JSON.
-
Method Details
-
write
Writes an object to JSON.- Parameters:
value- Object to write- Returns:
- the JSON output
- Throws:
JsonSerializationException- if an exception occurs while writing the output
-
write
Writes an object to JSON.- Parameters:
value- Object to writectx- Context for the full writing process- Returns:
- a
Stringobject. - Throws:
JsonSerializationException- if an exception occurs while writing the output
-
getSerializer
JsonSerializer<T> getSerializer()getSerializer.
- Returns:
- a
JsonSerializerobject.
-