Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version BRIDGE_21.1.3
Div
Classe2e-refDiv
Rp
Syntax
Code Block
languagenone
set aString = anObject.classToJson()
set aString = anObject.classToJson(options)
Semantics

The operation classToJson() takes any object (anObject) and tries to map it to a JSON string aString. If this is not possible, an error is raised.
JSON types and xUML types are mapped as listed in chapter jsonToClass.

Builder 7.5.0 You can hide attributes from being serialized by applying stereotype <<E2EPrivate>>. Refer to Hiding Attributes From Interfaces for more information.

SubstitutablesanObjectAny object. 
aStringTarget JSON document as String.
options

The optional parameter is an object of type ComposerOptions.

...

Image Added

Its attribute is:

AttributeTypeDescriptionAllowed Values
compactBooleanBuilder 7.0.0-beta3 When compact is true, the JSON composer will generate compact JSON, otherwise it will generate pretty JSON. The default behavior of classToJson() (i.e. when called without options) is equivalent to compact=false.trueGenerate compact JSON.
falseGenerate pretty JSON (default).
keepNullsBooleanWhen keepNulls is true, attributes of anObject with NULL values will be rendered to the JSON object, otherwise they will be left out completely (see also chapter NULL Values). The default behavior of classToJson() (i.e. when called without options) is equivalent to keepNulls=false.trueRender NULL attributes to the JSON object.
falseLeave out NULL attributes (default).
writeTypeDiscriminatorBoolean

Multiexcerpt include
SpaceWithExcerptINTERNAL
MultiExcerptNamewriteTypeDiscriminator
PageWithExcerptINTERNAL:_bridge_excerpts
This is necessary if you want to convert the generated JSON back to an xUML class using jsonToClass().

Runtime versions before 2021.6 will ignore the value.

trueWrite xUML type discriminator (default).
falseDo not write xUML type discriminator.
Examples
Code Block
languagenone
set addressAsJSONDocument = myAddress.classToJson();

Multiexcerpt include
MultiExcerptNameJSON_userManager
nopaneltrue
PageWithExcerptINTERNAL:_examples_BRIDGE