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, com.fasterxml.jackson.databind.ObjectMapper mapper)
      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,
                                     com.fasterxml.jackson.databind.ObjectMapper mapper)
                              throws java.io.IOException
        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
        mapper - 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.IOException
        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
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.