public final class JSONObjectToObjectExtensions
extends java.lang.Object
JSONObjectToObjectExtensions converts json strings to java object and java
collections.| Constructor and Description |
|---|
JSONObjectToObjectExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
toObject(@NonNull org.json.JSONObject jsonObject,
@NonNull java.lang.Class<T> clazz,
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
Transforms the given json object into a java object
|
static <T> java.util.List<T> |
toObjectList(@NonNull org.json.JSONArray jsonArray,
@NonNull java.lang.Class<T> elementClass)
Transforms the given
JSONArray into a java object List. |
public static <T> T toObject(@NonNull
@NonNull org.json.JSONObject jsonObject,
@NonNull
@NonNull java.lang.Class<T> clazz,
@NonNull
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
throws java.io.IOException
T - the generic typejsonObject - the json objectclazz - the clazz of the generic typemapper - the object mapperjava.io.IOException - Signals that an I/O exception has occurredpublic static <T> java.util.List<T> toObjectList(@NonNull
@NonNull org.json.JSONArray jsonArray,
@NonNull
@NonNull java.lang.Class<T> elementClass)
throws java.io.IOException
JSONArray into a java object List.T - the generic typejsonArray - the json array the element class of the generic typeelementClass - the element classjava.io.IOException - Signals that an I/O exception has occurred.