Class JSONDefaultConverter

java.lang.Object
com.blackrook.json.JSONDefaultConverter
All Implemented Interfaces:
JSONConverter<Object>

public class JSONDefaultConverter extends Object implements JSONConverter<Object>
Default converter for all types of objects that are not a part of the annotated conversions. The default converter is meant to cover Enum types, Map types, and other types that implement Iterable, such as Lists, Sets, and other implementations of Collection.

This is a one-way converter - this goes from Java object to JSON, and not back. It is not recommended to use this converter directly, as this is a catch-all for common conversions without explicit structure.

Author:
Matthew Tropiano
  • Constructor Details

    • JSONDefaultConverter

      public JSONDefaultConverter()
  • Method Details

    • getJSONObject

      public JSONObject getJSONObject(Object object)
      Description copied from interface: JSONConverter
      Returns a JSON object that represents this object instance (and its contents). The policy of this method is to help return something that can be converted back to Java via JSONConverter.getObject(JSONObject) with close-to or dead-on 100% equivalence.
      Specified by:
      getJSONObject in interface JSONConverter<Object>
      Parameters:
      object - the object to inspect.
      Returns:
      an accurate JSONObject that represents this object.
    • getObject

      public Object getObject(JSONObject jsonObject)
      Returns null.
      Specified by:
      getObject in interface JSONConverter<Object>
      Parameters:
      jsonObject - the JSON Object to convert.
      Returns:
      an accurate object from the JSON.