T - Type of the object to writepublic interface ObjectWriter<T>
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"}
| Modifier and Type | Method and Description |
|---|---|
JsonSerializer<T> |
getSerializer()
getSerializer.
|
String |
write(T value)
Writes an object to JSON.
|
String |
write(T value,
JsonSerializationContext ctx)
Writes an object to JSON.
|
String write(T value) throws JsonSerializationException
value - Object to writeJsonSerializationException - if an exception occurs while writing the outputString write(T value, JsonSerializationContext ctx) throws JsonSerializationException
value - Object to writectx - Context for the full writing processString object.JsonSerializationException - if an exception occurs while writing the outputJsonSerializer<T> getSerializer()
getSerializer.
JsonSerializer object.Copyright © 2020. All rights reserved.