Annotation Type JsonXML
-
@Documented @Retention(RUNTIME) @Target({METHOD,TYPE,PARAMETER}) public @interface JsonXML
The
JsonXMLannotation is used to configure the JSON serialization and deserialization process. It may be placed on a- a model type (e.g. a JAXB-annotated class) to configure serialization and deserialization of that type,
- a JAX-RS resource method to configure serialization of the result type,
- a parameter of a JAX-RS resource method to configure deserialiation of the parameter type.
If an annotations is present at a model type and a resource method or parameter, the latter overrides the model type annotation.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanautoArrayTrigger arrays automatically?booleanautoPrimitiveConvert element text to number/boolean/null primitives automatically?String[]multiplePathsSpecify array paths.booleannamespaceDeclarationsWhether to write namespace declarations.charnamespaceSeparatorNamespace prefix separator.booleanprettyPrintFormat output for better readability?booleanvirtualRootJSON documents may have have multiple root properties.
-
-
-
Element Detail
-
virtualRoot
boolean virtualRoot
JSON documents may have have multiple root properties. However, XML requires a single root element. This property states whether to treat the root as a "virtual" element, which will be removed from the stream when writing and added to the stream when reading. The root element name will be determined from an
@XmlRootElementor@XmlTypeannotation.The default value is
false(i.e. no virtual root).- Default:
- false
-
-
-
multiplePaths
String[] multiplePaths
Specify array paths. Paths may be absolute or relative (without leading
'/'), where names are separated by'/'and may be prefixed. The root element is included in a multiple path if and only ifvirtualRootis set tofalse(i.e. the root does appear in the JSON representation).E.g. for
{ "alice" : { "bob" : [ "edgar", "charlie" ], "peter" : null } }with
virtualRoot == falsewe would specify"/alice/bob","alice/bob"or"bob"as multiple path.On the other hand, when setting
virtualRoot == true, our JSON representation will change to{ "bob" : [ "edgar", "charlie" ], "peter" : null }and we would specify"/bob"or"bob"as multiple path.- Default:
- {}
-
-