Serializes the BUFFER's current row to JSON or XML format.
Return type: LOGICAL
Applies to: Buffer object handle
SERIALIZE-ROW ( target-format , target-type , { file | stream | stream-handle | memptr | longchar } [ , formatted [ , encoding [ , omit-initial-values [ , omit-outer-object ] ] ] ] ) |
For more information about using ABL unnamed output streams, see the DEFINE STREAM statement reference entry and the chapter on alternate I/O sources in OpenEdge Development: Programming Interfaces. For more information about using WebSpeed-defined output streams, see OpenEdge Application Server: Developing WebSpeed Applications.
The AVM saves the buffer's current row 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 LONGCHAR, the AVM saves the LONGCHAR variable in UTF-8.
If the LONGCHAR variable's code page is fixed (that is, set using the FIX-CODEPAGE statement) and the fixed code page is not equivalent to the character encoding you specify in the encoding option, the SERIALIZE-ROW( ) method generates an error and returns FALSE. The buffer's current row is not saved to the LONGCHAR.
If you specify the Unknown value (?), the method uses the default value of FALSE.
When target-format is "JSON", the encoding name must specify a Unicode transformation format. Valid values are "UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", and "UTF-32LE".
When target-format is "XML", the encoding name must be an Internet Assigned Numbers Authority (IANA) name supported by the ABL XML Parser. For a list of supported IANA encodings and their corresponding ABL code pages, see the following table in the ENCODING attribute reference entry.
When working with large ProDataSets, omitting fields containing their initial values can yield smaller output size, more efficient network transfers, and performance gains with the READ-JSON( ) and SERIALIZE-ROW( ) methods.
This behavior applies both to temp-table fields that have the default initial value for its data type, and for fields that have an initial value set with the ABL INITIAL option.
Although using the omit-initial-values option can give your application performance and resource use improvements, you must be sure that the consumers of the generated output will correctly handle it. The ABL READ-JSON( ) and READ-XML( ) methods always populate created records with initial values from the temp-table or ProDataSet definition. Other applications might not do this.
If you specify the Unknown value (?), the method uses the default value of FALSE.
omit-outer-object is only valid when target-format is "JSON". If omit-outer-object is TRUE when target-type is "XML", the AVM generates an error and returns FALSE.