Feature List
The following is a list of the most notable features available in Json-lib.
Java
The following options are configurable with JsonConfig:
- bidirectional serialization, supports Maps, Collections, arrays (primitives, multidimensional), beans, DynaBeans, Enums & Annotations (jdk15 package only)
- supports custom serialization with 3 schemes:
- the bean implements JSONString interface
- register a JsonBeanProcessor for the whole bean
- register a JsonValueProcessor for a bean property (key and/or type)
- register a DefaultValueProcessor for returning a default value when a null reference is encountered
- plugin your own strategy for selecting a JsonBeanProcessor with JsonBeanProcessorMatcher
- plugin your own strategy for selecting a DefaultValueProcessor with DefaultValueProcessorMatcher
- modify the target property name when transforming from JSON to Java if the name is not a valid JavaIdentifier
- skip modifying map keys when transforming form JSON to Java if the key is not a valid JavaIdentifier
- register your own JavaIdentifierTransformer strategy
- plugin your own strategy for setting properties into a bean when transforming from JSON to Java thanks to PropertySetStrategy
- publish events when building a JSONObject or JSONarray. The available events are:
- object start/end
- array start/end
- propertySet
- elementAdded
- warning (recoverable)
- error (exception)
- Cycle detection, there are two default strategies (default throws an exception), you can register your own
- Skip transient fields when serailizing to JSON (default=don't skip)
- Skip JAP @Transient annotated methods when serailizing to JSON (default=don't skip)
- Exclude bean properties and/or map keys when serailizing to JSON (default=['class','metaClass','declaringClass'])
- Filters provide a finer detail for excluding/including properties when serializing to JSON or transforming back to Java
- plugin your own strategy for instatiating beans if they do now follow the no-args constructor rule
- default JavaBean instantiton strategy accepts package protected and private no-args constructor (Hibernate friendly)
- JSONObject implements java.util.Map and java.util.Comparable
- JSONArray implements java.util.List and java.util.Comparable
- JSONObject, JSONArray and JSONNull implement a base interface: JSON
- JSONAssert, a test-friendly class for testing JSON values