Class GsonJsonObjectUnmarshaller<T>
java.lang.Object
org.springframework.batch.infrastructure.item.json.GsonJsonObjectUnmarshaller<T>
- Type Parameters:
T- type of objects to unmarshal
- All Implemented Interfaces:
JsonObjectUnmarshaller<T>
A json object unmarshaller that uses Google
Gson to unmarshal a json representation into an object.
- Since:
- 6.1
- Author:
- Mahmoud Ben Hassine
-
Constructor Summary
ConstructorsConstructorDescriptionGsonJsonObjectUnmarshaller(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type) Create a newGsonJsonObjectUnmarshallerwith the providedGson.GsonJsonObjectUnmarshaller(com.google.gson.Gson gson, Class<T> type) Create a newGsonJsonObjectUnmarshallerwith the providedGson.GsonJsonObjectUnmarshaller(com.google.gson.reflect.TypeToken<T> type) Create a newGsonJsonObjectUnmarshallerwith a defaultGson.GsonJsonObjectUnmarshaller(Class<T> type) Create a newGsonJsonObjectUnmarshallerwith a defaultGson. -
Method Summary
-
Constructor Details
-
GsonJsonObjectUnmarshaller
Create a newGsonJsonObjectUnmarshallerwith a defaultGson.- Parameters:
type- the target type
-
GsonJsonObjectUnmarshaller
Create a newGsonJsonObjectUnmarshallerwith a defaultGson. Use this constructor for parameterized target types, for examplenew TypeToken<Map<String, Object>>() {}.- Parameters:
type- the target type
-
GsonJsonObjectUnmarshaller
Create a newGsonJsonObjectUnmarshallerwith the providedGson.- Parameters:
gson- the gson object to usetype- the target type
-
GsonJsonObjectUnmarshaller
public GsonJsonObjectUnmarshaller(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type) Create a newGsonJsonObjectUnmarshallerwith the providedGson. Use this constructor for parameterized target types, for examplenew TypeToken<Map<String, Object>>() {}.- Parameters:
gson- the gson object to usetype- the target type
-
-
Method Details
-
unmarshal
Unmarshal the provided json into an object of the target type.- Specified by:
unmarshalin interfaceJsonObjectUnmarshaller<T>- Parameters:
json- the json representation of the object- Returns:
- the unmarshalled object
- Throws:
ParseException- if the json cannot be unmarshalled
-