Package io.github.astrapi69.json
Class JSONObjectToObjectExtensions
- java.lang.Object
-
- io.github.astrapi69.json.JSONObjectToObjectExtensions
-
public final class JSONObjectToObjectExtensions extends java.lang.ObjectThe classJSONObjectToObjectExtensionsconverts json strings to java object and java collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TtoObject(org.json.JSONObject jsonObject, java.lang.Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper)Transforms the given json object into a java objectstatic <T> java.util.List<T>toObjectList(org.json.JSONArray jsonArray, java.lang.Class<T> elementClass)Transforms the givenJSONArrayinto a java objectList.
-
-
-
Method Detail
-
toObject
public static <T> T toObject(org.json.JSONObject jsonObject, java.lang.Class<T> clazz, com.fasterxml.jackson.databind.ObjectMapper mapper) throws java.io.IOExceptionTransforms the given json object into a java object- Type Parameters:
T- the generic type- Parameters:
jsonObject- the json objectclazz- the clazz of the generic typemapper- the object mapper- Returns:
- the java object
- Throws:
java.io.IOException- Signals that an I/O exception has occurred
-
toObjectList
public static <T> java.util.List<T> toObjectList(org.json.JSONArray jsonArray, java.lang.Class<T> elementClass) throws java.io.IOExceptionTransforms the givenJSONArrayinto a java objectList.- Type Parameters:
T- the generic type- Parameters:
jsonArray- the json array the element class of the generic typeelementClass- the element class- Returns:
- the list with the java objects
- Throws:
java.io.IOException- Signals that an I/O exception has occurred.
-
-