JSON Parser and Generator.
This class provides some static methods to convert POJOs to and from JSON notation. The mapping from JSON to java is:
object ==> Map array ==> Object[] number ==> Double or Long string ==> String null ==> null bool ==> Boolean
The java to JSON mapping is:
String --> string Number --> number Map --> object List --> array Array --> array null --> null Boolean--> boolean Object --> string (dubious!)
The interface {@link JSON.Convertible} may be implemented by classes thatwish to externalize and initialize specific fields to and from JSON objects. Only directed acyclic graphs of objects are supported.
The interface {@link JSON.Generator} may be implemented by classes that knowhow to render themselves as JSON and the {@link #toString(Object)} methodwill use {@link JSON.Generator#addJSON(Appendable)} to generate the JSON.The class {@link JSON.Literal} may be used to hold pre-generated JSON object.
The interface {@link JSON.Convertor} may be implemented to provide staticconverters for objects that may be registered with {@link #registerConvertor(Class,Convertor)}. These converters are looked up by class, interface and super class by {@link #getConvertor(Class)}.
If a JSON object has a "class" field, then a java class for that name is loaded and the method {@link #convertTo(Class,Map)} is used to find a{@link JSON.Convertor} for that class.
If a JSON object has a "x-class" field then a direct lookup for a {@link JSON.Convertor} for that class name is done (without loading the class).