Class ObjectToJson


  • public class ObjectToJson
    extends java.lang.Object

    auto convert object to json

    Version:
    1.1
    Author:
    cho wonwoo
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectToJson()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.json.simple.JSONObject toJson​(java.lang.Object obj)
      Create a JsonObject and bind data from the given object as parameter.
      static java.lang.String toJsonString​(java.lang.Object obj)
      Create String and write data from the given object as parameter.
      • Methods inherited from class java.lang.Object

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

      • ObjectToJson

        public ObjectToJson()
    • Method Detail

      • toJson

        public static org.json.simple.JSONObject toJson​(java.lang.Object obj)
                                                 throws java.lang.IllegalAccessException
        Create a JsonObject and bind data from the given object as parameter.
        Parameters:
        obj - Object to get data.
        Returns:
        jsonObject converted from given object.
        Throws:
        java.lang.IllegalAccessException - argument is a instance of String or primitive value
      • toJsonString

        public static java.lang.String toJsonString​(java.lang.Object obj)
                                             throws java.lang.IllegalAccessException
        Create String and write data from the given object as parameter.
        Parameters:
        obj - Object to get data.
        Returns:
        JSON formatted String converted from given object
        Throws:
        java.lang.IllegalAccessException