Syntax 3

Description

Exports data from the specified buffer(s) and/or DataWindowChild to a plain JSON string or DataWindow JSON string.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, and DataStore object, except for those with the Composite, Crosstab, OLE 2.0, or RichText presentation styles.


Syntax

PowerBuilder

string dwcontrol.ExportJson( boolean primarydata, boolean filterdata, boolean deletedata, boolean dwcdata {, boolean format} )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or DataWindowChild.

primarydata

A boolean specifying whether to export the data from the primary buffer.

  • True -- to export

  • False -- not to export

filterdata

A boolean specifying whether to export the data from the filter buffer.

  • True -- to export

  • False -- not to export

deletedata

A boolean specifying whether to export the data from the delete buffer.

  • True -- to export

  • False -- not to export

dwcdata

A boolean specifying whether to export the DataWindowChild data.

  • True -- to export. If it is to export the DataWindowChild data, data from all buffers will be exported to a plain JSON, regardless of the value of the other arguments.

  • False -- not to export

format (optional)

A boolean specifying the JSON format.

  • True indicates the DataWindow JSON

  • False indicates the plain JSON. The default is false.

See the section called “Supported JSON formats” in Application Techniques for details about the JSON format.


Return value

String. Returns the JSON string if it succeeds. Returns the empty string ("") if an error occurs.

The method returns null if any of the following:

  • any argument's value is null

  • the DataWindow object (dataobject) is invalid

  • the DataWindow presentation style is unsupported, such as Composite, Crosstab, OLE 2.0, or RichText

Usage

The Number data type is handled as Double data type; 15 digits of precision is supported; and it will be written in scientific notation if it exceeds 15 digits.

The Decimal{0} data type is handled as Double data type; it has no fractional part, and the digits in the fractional part (if any) will be rounded to the integral part; 15 digits of precision is supported; and it will be written in scientific notation if it exceeds 15 digits.

The Decimal{n} data type is handled as Double data type; it can have n digits in the fractional part, and the following digits (if any) will be rounded; 15 digits of precision is supported; and it will be written in scientific notation if it exceeds 15 digits.

Examples

This example exports the data from the primary buffer and the filter buffer of the DataWindow to a plain JSON string:

string ls_PlainJson 
ls_PlainJson = dw_1.ExportJson(true, true, false, false)

This example exports the data from every buffer of the DataWindow and the DataWindowChild to a DataWindow JSON string:

string ls_DWJson
ls_DWJson = dw_1.ExportJson(true, true, true, true, true)

See also

ImportJson

ImportJsonByKey