Class JSONModeller


  • public class JSONModeller
    extends java.lang.Object
    Turns Java object into JSON object tree and vice versa.
    Author:
    homac
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T toJavaObject​(java.lang.Object jsonAny, java.lang.Class<T> targetType)  
      <T> T toJavaObject​(java.lang.Object jsonAny, T targetObject)  
      java.lang.Object toJSON​(java.lang.Object javaObject)
      Encodes the given Java object into a JSON object.
      java.lang.Object toJSON​(java.lang.Object o, java.lang.Class<?> referenceType)
      returns a JSONObject, JSONArray or primitive value (including String) depending on the given object and reference type.
      • Methods inherited from class java.lang.Object

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

      • toJavaObject

        public <T> T toJavaObject​(java.lang.Object jsonAny,
                                  T targetObject)
                           throws JSONException
        Throws:
        JSONException
      • toJavaObject

        public <T> T toJavaObject​(java.lang.Object jsonAny,
                                  java.lang.Class<T> targetType)
                           throws JSONException
        Throws:
        JSONException
      • toJSON

        public java.lang.Object toJSON​(java.lang.Object javaObject)
                                throws JSONException
        Encodes the given Java object into a JSON object.
        Throws:
        JSONException
      • toJSON

        public java.lang.Object toJSON​(java.lang.Object o,
                                       java.lang.Class<?> referenceType)
                                throws JSONException
        returns a JSONObject, JSONArray or primitive value (including String) depending on the given object and reference type.
        Parameters:
        o - Object to be encoded.
        referenceType - Class of the object or some subclass, in case you want just a particular subset of the members
        Throws:
        JSONException