Package com.mercadopago.serialization
Class Serializer
- java.lang.Object
-
- com.mercadopago.serialization.Serializer
-
public class Serializer extends Object
Serializer class, responsible for objects serialization and deserialization.
-
-
Constructor Summary
Constructors Constructor Description Serializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends MPResource>
MPElementsResourcesPage<T>deserializeElementsResourcesPageFromJson(Type type, String jsonObject)Method responsible for deserialize json to ElementsResources.static <T extends MPResource>
TdeserializeFromJson(Class<T> clazz, String jsonObject)Method responsible for deserialize objects.static <T extends MPResource>
MPResourceList<T>deserializeListFromJson(Class<T> clazz, String jsonObject)Method responsible for deserialize objects.static <T extends MPResource>
MPResultsResourcesPage<T>deserializeResultsResourcesPageFromJson(Type type, String jsonObject)Method responsible for deserialize json to ResultsResources.static booleanisJsonValid(String json)Verify if json is valid.static <T> com.google.gson.JsonObjectserializeToJson(T resource)Method responsible for serialize objects.
-
-
-
Method Detail
-
deserializeFromJson
public static <T extends MPResource> T deserializeFromJson(Class<T> clazz, String jsonObject) throws MPJsonParseException
Method responsible for deserialize objects.- Type Parameters:
T- class type.- Parameters:
clazz- class.jsonObject- json object.- Returns:
- object.
- Throws:
MPJsonParseException- if json cannot be deserialized to an MPResource
-
deserializeResultsResourcesPageFromJson
public static <T extends MPResource> MPResultsResourcesPage<T> deserializeResultsResourcesPageFromJson(Type type, String jsonObject) throws MPJsonParseException
Method responsible for deserialize json to ResultsResources.- Type Parameters:
T- generic type- Parameters:
type- typejsonObject- jsonObject- Returns:
- MPResultsResourcesPage deserialized MPResource
- Throws:
MPJsonParseException- if json cannot be parsed to ResultsResourcesPage
-
deserializeElementsResourcesPageFromJson
public static <T extends MPResource> MPElementsResourcesPage<T> deserializeElementsResourcesPageFromJson(Type type, String jsonObject) throws MPJsonParseException
Method responsible for deserialize json to ElementsResources.- Type Parameters:
T- generic type- Parameters:
type- typejsonObject- jsonObject- Returns:
- MPElementsResourcesPage
- Throws:
MPJsonParseException- if json cannot be parsed to MPElementsResourcesPage
-
deserializeListFromJson
public static <T extends MPResource> MPResourceList<T> deserializeListFromJson(Class<T> clazz, String jsonObject) throws MPJsonParseException
Method responsible for deserialize objects.- Type Parameters:
T- type- Parameters:
clazz- clazzjsonObject- jsonObject- Returns:
- MPResourceList
- Throws:
MPJsonParseException- if json cannot be parsed to ResultsResourcesPage
-
serializeToJson
public static <T> com.google.gson.JsonObject serializeToJson(T resource)
Method responsible for serialize objects.- Type Parameters:
T- class type.- Parameters:
resource- resource.- Returns:
- JsonObject.
-
isJsonValid
public static boolean isJsonValid(String json) throws IOException
Verify if json is valid.- Parameters:
json- json- Returns:
- boolean
- Throws:
IOException- exception
-
-