Package com.onfido.api
Class ApiJson<T>
- java.lang.Object
-
- com.onfido.api.ApiJson<T>
-
- Type Parameters:
T- the type parameter
public final class ApiJson<T> extends Object
A wrapper around Moshi's JsonAdapter for parsing and formatting JSON for Onfido's API.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tparse(String json)Coverts the provided json string to an object of type TList<T>parseList(String json)List<T>parseWrappedList(String json, String path)Parses a json array into a list of type T.StringtoJson(T t)Coverts the provided object of type T to a json string.StringtoPrettyJson(T t)Coverts the provided object of type T to a human readable json string.
-
-
-
Method Detail
-
toJson
public String toJson(T t)
Coverts the provided object of type T to a json string.- Parameters:
t- the object to be converted- Returns:
- the json string
-
toPrettyJson
public String toPrettyJson(T t)
Coverts the provided object of type T to a human readable json string.- Parameters:
t- the object to be converted- Returns:
- the string
-
parse
public T parse(String json) throws OnfidoException
Coverts the provided json string to an object of type T- Parameters:
json- the json string to be converted- Returns:
- the object made from the json string
- Throws:
OnfidoException- the onfido exception
-
parseWrappedList
public List<T> parseWrappedList(String json, String path) throws OnfidoException
Parses a json array into a list of type T.- Parameters:
json- the json string to be convertedpath- the path to the json array- Returns:
- the list made from the json string
- Throws:
OnfidoException- the onfido exception
-
parseList
public List<T> parseList(String json) throws OnfidoException
- Throws:
OnfidoException
-
-