Class JSONObjectToObjectExtensions


  • public final class JSONObjectToObjectExtensions
    extends java.lang.Object
    The class JSONObjectToObjectExtensions converts json strings to java object and java collections.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T toObject​(org.json.JSONObject jsonObject, java.lang.Class<T> clazz)
      Transforms the given json object into a java object
      static <T> java.util.List<T> toObjectList​(org.json.JSONArray jsonArray, java.lang.Class<T> elementClass)
      Transforms the given JSONArray into a java object List.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toObject

        public static <T> T toObject​(org.json.JSONObject jsonObject,
                                     java.lang.Class<T> clazz)
        Transforms the given json object into a java object
        Type Parameters:
        T - the generic type
        Parameters:
        jsonObject - the json object
        clazz - the clazz of the generic type
        Returns:
        the java object
      • toObjectList

        public static <T> java.util.List<T> toObjectList​(org.json.JSONArray jsonArray,
                                                         java.lang.Class<T> elementClass)
        Transforms the given JSONArray into a java object List.
        Type Parameters:
        T - the generic type
        Parameters:
        jsonArray - the json array the element class of the generic type
        elementClass - the element class
        Returns:
        the list with the java objects