Package org.dominokit.jacksonapt
Interface ObjectReader<T>
- Type Parameters:
T- Type of the read object
- All Known Subinterfaces:
ObjectMapper<T>
- All Known Implementing Classes:
AbstractObjectMapper,AbstractObjectReader,AbstractObjectWriter
public interface ObjectReader<T>
Reads a JSON input and return an object
Example :
public class Person {
public String firstName, lastName;
}
public interface PersonReader extends ObjectReader<Person> {}
PersonReader reader = new PersonReaderMapperImpl();
Person person = reader.read("{\"firstName\":\"Nicolas\",\"lastName\":\"Morel\"}");
person.firstName ==> "Nicolas"
person.lastName ==> "Morel"
- Version:
- $Id: $
- Author:
- Nicolas Morel
-
Method Summary
Modifier and Type Method Description JsonDeserializer<T>getDeserializer()getDeserializer.Tread(java.lang.String input)Reads a JSON input into an object.Tread(java.lang.String input, JsonDeserializationContext ctx)Reads a JSON input into an object.T[]readArray(java.lang.String input, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator)Reads a JSON input into an array object.T[]readArray(java.lang.String input, JsonDeserializationContext ctx, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator)Reads a JSON input into an array object.
-
Method Details
-
read
Reads a JSON input into an object.- Parameters:
input- JSON input to read- Returns:
- the read object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
read
Reads a JSON input into an object.- Parameters:
input- JSON input to readctx- Context for the full reading process- Returns:
- the read object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
readArray
T[] readArray(java.lang.String input, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator) throws JsonDeserializationExceptionReads a JSON input into an array object.- Parameters:
input- JSON input to readarrayCreator- Creator for initializing new instance of an array of specific length- Returns:
- the read array object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
readArray
T[] readArray(java.lang.String input, JsonDeserializationContext ctx, ArrayJsonDeserializer.ArrayCreator<T> arrayCreator) throws JsonDeserializationExceptionReads a JSON input into an array object.- Parameters:
input- JSON input to readctx- Context for the full reading processarrayCreator- Creator for initializing new instance of an array of specific length- Returns:
- the read array object
- Throws:
JsonDeserializationException- if an exception occurs while reading the input
-
getDeserializer
JsonDeserializer<T> getDeserializer()getDeserializer.
- Returns:
- a
JsonDeserializerobject.
-