Previous Next

Write( ) method (JsonConstruct)
Serializes the JsonConstruct (JsonObject or JsonArray) 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:
Access:
Applies to:
 
Syntax 
Write( INPUT stream-handle AS HANDLE,
       INPUT formatted AS LOGICAL)
 
Write( INPUT stream-handle AS HANDLE,
       INPUT formatted AS LOGICAL,
       INPUT encoding AS CHARACTER)
 
Write( INPUT-OUTPUT longchar AS LONGCHAR)
 
Write( INPUT-OUTPUT longchar AS LONGCHAR,
       INPUT formatted AS LOGICAL)
 
Write( INPUT-OUTPUT longchar AS LONGCHAR,
       INPUT formatted AS LOGICAL,
       INPUT encoding AS CHARACTER)
 
Write( INPUT memptr AS MEMPTR)
 
Write( INPUT memptr AS MEMPTR,
       INPUT formatted AS LOGICAL)
 
Write( INPUT memptr AS MEMPTR,
       INPUT formatted AS LOGICAL,
       INPUT encoding AS CHARACTER)
 
Write( OUTPUT character AS CHARACTER)
 
Write( OUTPUT character AS CHARACTER,
       INPUT formatted AS LOGICAL)
 
stream-handle
HANDLE variable that specifies a stream object handle. If the parameter is another handle type, a JsonError error 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-CODEPAGE statement and the fixed code page is not equivalent to the character encoding, this method raises a JsonError error.
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 executing SET-SIZE(memptr) = 0 on 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
An optional 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
An optional string 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".

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.