@Target(value={TYPE,CONSTRUCTOR,METHOD}) @Retention(value=CLASS) public @interface CompiledJson
If classes with this annotation reference another class which doesn't have this annotation, annotation processor will behave as they have @CompiledJson annotation (this can be controlled via compiler option). This can be used to create converters for objects which can't be modified.
| Modifier and Type | Optional Element and Description |
|---|---|
Class |
deserializeAs
Perform deserialization into a different type.
|
String |
discriminator
When used in mixin which doesn't have deserializeAs "discriminator":signature will be injected into JSON.
|
CompiledJson.Format[] |
formats
JSON can be encoded/decoded in several ways:
- object - standard attribute: value pair, eg: {"prop":123,"attr":"abc"} - array - no attributes, just values in array, eg: [123,"abc"] |
boolean |
minified
Deprecated.
|
String |
name
When used in mixin which doesn't have deserializeAs "$type":name will be injected into JSON.
|
Class |
namingStrategy |
CompiledJson.ObjectFormatPolicy |
objectFormatPolicy
Object format can be fine tuned to either:
- always include all properties - serialize only some properties |
CompiledJson.Behavior |
onUnknown
Specify how to handle unknown property during object processing.
|
CompiledJson.TypeSignature |
typeSignature
Abstract types used as properties by default include type signature information so they can be properly deserialized.
|
public abstract CompiledJson.Format[] formats
Array format [prop1, prop2, prop3] is useful when sending known format on both sides since it assumes fixed property order and all properties must be known by both sides. index() parameter can be used to control the ordering.
Serialization will be done via the first available format.
public abstract CompiledJson.ObjectFormatPolicy objectFormatPolicy
This can be defined per DslJson instance via omitDefaults property during initialization through: skipDefaultValues
To fine tune the behavior on class level specific policy can be set on the class which will override the global setting.
By default minimal serialization will only include properties which have non-default values. If some properties need to be always included regardless, this can be done via additional annotation on property level.
public abstract Class namingStrategy
@Deprecated public abstract boolean minified
public abstract CompiledJson.Behavior onUnknown
public abstract CompiledJson.TypeSignature typeSignature
public abstract Class deserializeAs
public abstract String discriminator
public abstract String name
Copyright © 2023. All rights reserved.