Write( ) method (JsonObject)
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Serializes the JsonObect and any
JsonConstructs it references. This is a recursive process resulting in a
JSON representation of the entire set of JsonObjects and
JsonArrays. On successful execution the method returns TRUE.
Return type: LOGICAL
Access: PUBLIC
Applies to: Progress.Json.ObjectModel.JsonObject class
Syntax
|
- stream-handle
- HANDLE variable that specifies a stream object handle. If the
parameter is another handle type, a
JsonErrorerror is raised. - longchar
- A LONGCHAR variable to contain the JSON string in memory.
The AVM saves the JSON string to the LONGCHAR variable in the code page that corresponds to the character encoding you specify in the encoding option. If you do not specify a character encoding for the JSON string, the AVM saves the LONGCHAR variable in "
UTF-8".If the LONGCHAR variable's code page is fixed using the
FIX-CODEPAGEstatement and the fixed code page is not equivalent to the character encoding, this method raises aJsonErrorerror. - memptr
- A MEMPTR variable to contain the JSON string in memory. If you do not
specify the encoding parameter, the AVM encodes the text written to the MEMPTR as
"
UTF-8". This method allocates the required amount of memory for the JSON string and sets the size of the variable. If the MEMPTR contains allocated memory when the method is called, that memory may be reallocated during the execution of the method. When you are finished using the MEMPTR, you must free the associated memory, by executingSET-SIZE(memptr) = 0on the MEMPTR. - character
- A CHARACTER variable to contain the JSON string in memory. An error is raised if the JSON string cannot be transcoded from Unicode to -cpinternal.
- formatted
- A LOGICAL expression where TRUE directs the AVM to format the JSON
string in a hierarchical manner using extra white space, carriage returns,
and line feeds. The default value is FALSE.
If you specify the Unknown value (
?), the method uses the default value of FALSE. - encoding
- A CHARACTER expression indicating the Unicode Transformation
Format (UTF) of the JSON string to be written. Valid values for
UTF are "
UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", and "UTF-32LE". If the value is the empty string (""), the Unknown value (?), or not given, the parameter defaults to "UTF-8".
Notes
- Binary types, including BLOB, RAW, and ROWID are base64-encoded/decoded. See Data type mapping in Use JSON with ABL Applications for more information.