You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 2
Next »
Syntax |
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() Operation. Builder 7.5.0 You can hide attributes from being serialized by applying stereotype <<E2EPrivate>>. Refer to Hiding Attributes From Interfaces for more information. |
---|
Substitutables | anObject | Any object. |
---|
aString | Target JSON document as String. |
options | The optional parameter is an object of type ComposerOptions.
Its attribute is: Attribute | Type | Description | Allowed Values |
---|
compact | Boolean | Builder 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. | true | Generate compact JSON. | false | Generate pretty JSON. | keepNulls | Boolean | When 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. | true | Render NULL attributes to the JSON object. | false | Leave out NULL attributes. |
|
Examples |
set addressAsJSONDocument = myAddress.classToJson();
|
---|