ExportJson

Exports data from the DataWindow control, DataStore object, or DataWindowChild object to the JSON string.

Syntax 1

Description

Exports data from the DataWindow primary buffer to a simple-format or standard-format 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 format} )

Argument

Description

dwcontrol

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

format (optional)

A boolean specifying the JSON format.

  • True indicates the standard format

  • False (default) indicates the simple format.

See JSON formats for details about the simple and standard 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

Examples

This example exports data from the primary buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson()

This example exports data from the primary buffer of the DataWindow to a standard-format JSON string:

string ls_StandardJson 
ls_StandardJson = dw_1.ExportJson(true)

See also

ImportJson

ImportJsonByKey

Syntax 2

Description

Exports all rows or only the changed rows from all or specified buffers to a simple-format or standard-format 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( {DWBuffer dwbuffer,} boolean changedonly, boolean format )

Argument

Description

dwcontrol

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

dwbuffer (optional)

A value of the dwBuffer enumerated datatype identifying the DataWindow buffer from which you want to export the data. For a list of valid values, see DWBuffer.

If not specified, all of the DataWindow buffers will be exported, however, the data for DataWindowChild will not be exported (even if changedonly is false).

changedonly

A boolean specifying the changing flag.

  • True -- to export the changed rows only (and all rows of the Delete buffer).

  • False -- to export all rows. The default is false.

format

A boolean specifying the JSON format.

  • True indicates the standard format.

  • False indicates the simple format. The default is false.

See JSON formats for details about the simple and standard 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

Examples

This example exports the changed rows from all buffers of the DataWindow to a standard-format JSON string:

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

This example exports the changed rows from the primary buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson(Primary!, true, false)

See also

ImportJson

ImportJsonByKey

Syntax 3

Description

Exports data from the specified buffer(s) and/or DataWindowChild to a simple-format or standard-format 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 simple-format JSON, regardless of the value of the other arguments.

  • False -- not to export

format (optional)

A boolean specifying the JSON format.

  • True indicates the standard format.

  • False indicates the simple format. The default is false.

See JSON formats for details about the simple and standard 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

Examples

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

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

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

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

See also

ImportJson

ImportJsonByKey

Syntax 4

Description

Exports all data or the specified rows and/or columns from the specified buffer to a simple-format or standard-format 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( DWBuffer dwbuffer {, long startrow {, long endrow {, long startcolumn {, long endcolumn } } } } {, boolean format } )

Argument

Description

dwcontrol

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

dwbuffer

A value of the dwBuffer enumerated datatype identifying the DataWindow buffer from which you want to export the data. For a list of valid values, see DWBuffer.

If not specified, all of the DataWindow buffers will be exported, however, the data for DataWindowChild will not be exported (even if changedonly is false).

startrow (optional)

The number of the first detail row in the buffer that you want to export. The default is 1. If it is 0 or negative, 1 is used.

endrow (optional)

The number of the last detail row in the buffer that you want to export. The default is the rest of the rows. If it is 0 or negative, it indicates the rest of rows.

startcolumn (optional)

The number of the first column in the buffer that you want to export. The default is 1. If it is 0 or negative, 1 is used.

endcolumn (optional)

The number of the last column in the buffer that you want to export. The default is the rest of the columns. If it is 0 or negative, it indicates the rest of columns.

format (optional)

A boolean specifying the JSON format.

  • True indicates the standard format.

  • False indicates the simple format. The default is false.

See JSON formats for details about the simple and standard 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

Examples

This example exports data from the delete buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson(Delete!)

This example exports data from the filter buffer of the DataWindow to a standard-format JSON string:

string ls_StandardJson 
ls_StandardJson = dw_1.ExportJson(Filter!, true)

This example exports data in rows 2 through the end from the primary buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson(Primary!, 2)

This example exports data in rows 2 through the end from the primary buffer of the DataWindow to a standard-format JSON string:

string ls_StandardJson
ls_StandardJson = dw_1.ExportJson(Primary!, 2, true)

This example exports data in rows 1 through 10 from the primary buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson(Primary!, 1, 10)

This example exports data in rows 1 through 10 from the primary buffer of the DataWindow to a standard-format JSON string:

string ls_StandardJson 
ls_StandardJson = dw_1.ExportJson(Primary!, 1, 10, true)

This example exports data in rows 1 through 10 and columns 2 through the end from the primary buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson(Primary!, 1, 10, 2)

This example exports data in rows 1 through 10 and columns 2 through the end from the primary buffer of the DataWindow to a standard-format JSON string:

string ls_StandardJson
ls_StandardJson = dw_1.ExportJson(Primary!, 1, 10, 2, true)

This example exports data in rows 1 through 10 and columns 2 through 5 from the primary buffer of the DataWindow to a simple-format JSON string:

string ls_SimpleJson 
ls_SimpleJson = dw_1.ExportJson(Primary!, 1, 10, 2, 5)

This example exports data in rows 1 through 10 and columns 2 through 5 from the primary buffer of the DataWindow to a standard-format JSON string:

string ls_StandardJson
ls_StandardJson = dw_1.ExportJson(Primary!, 1, 10, 2, 5, true)

See also

ImportJson

ImportJsonByKey