Read( ) method (JsonObject)

Uses the data from a ProDataSet, temp-table, or buffer handle to generate a JsonObject. The current contents of the JsonObject are removed.

Return type: LOGICAL

Access: PUBLIC

Applies to: Progress.Json.ObjectModel.JsonObject class

Syntax

Read( INPUT DATASET-HANDLE pds-handle )

Read( INPUT DATASET-HANDLE pds-handle,
      INPUT omit-initial-values AS LOGICAL )

Read( INPUT DATASET-HANDLE pds-handle,
      INPUT omit-initial-values AS LOGICAL,
      INPUT read-before-image AS LOGICAL)

Read( INPUT TABLE-HANDLE tt-handle )

Read( INPUT TABLE-HANDLE tt-handle,
      INPUT omit-initial-values AS LOGICAL )

Read( INPUT buffer-handle AS HANDLE )

Read( INPUT buffer-handle AS HANDLE,
      INPUT omit-initial-values AS LOGICAL )
pds-handle
A HANDLE to either a static ProDataSet or dynamic ProDataSet to be used as the source for setting the JsonObject. If this value is the Unknown value (?), a JsonError is raised.
tt-handle
A HANDLE to either a static temp-table or dynamic temp-table to be used as the source for setting the JsonObject. If this value is the Unknown value (?) a JsonError is raised.
buffer-handle
A HANDLE to either a static temp-table buffer or dynamic temp-table buffer to be used as the source for setting the JsonObject. If this value is the Unknown value (?), a JsonError is raised.
Note: The value of the JsonObject is based on the one row in the buffer, not the entire table. This behavior differs from WRITE-JSON( ) and WRITE-XML( ). Those methods process the entire table associated with the buffer.
omit-initial-values
A LOGICAL expression where TRUE directs the AVM to exclude temp-table fields containing their initial values from the JSON object, and FALSE directs the AVM to include all temp-table field data in the JSON. The default value is FALSE. If you specify the Unknown value (?), the method uses the default value of FALSE.

When working with large ProDataSets, omitting fields containing their initial values can yield smaller JSON values, more efficient network transfers, and performance gains with the JsonObject( ) constructor.

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. When a temp-table handle is passed to JsonObject:Read( ), the JsonObject is set to a single property.

read-before-image
A LOGICAL expression where TRUE directs the AVM to include ProDataSet before-image data and error information in the JSON object. The default value is FALSE. If you specify the Unknown value (?), the method uses the default value of FALSE.

The following example shows a temp-table definition passed to JsonObject:Read( ):

DEFINE VARIABLE httCust AS HANDLE NO-UNDO.
DEFINE VARIABLE myObj AS JsonObject NO-UNDO.
DEFINE VARIABLE myLongchar AS LONGCHAR NO-UNDO.

DEFINE TEMP-TABLE ttCust
  FIELD CustNum AS INTEGER
  FIELD Name    AS CHARACTER
  FIELD NewCust AS LOGICAL.

/*
 .
 . Load temp-table
 .
 */

httCust = TEMP-TABLE ttCust:HANDLE.
myObj = NEW JsonObject().
myObj:Read(TABLE-HANDLE httCust).
myObj:Write(myLongchar, TRUE).

The following is the resultant JSON construct tree, myLongchar:

{"ttCust":
  [
    {"CustNum": 1, "Name": "Lift Tours", "NewCust": false },
    {"CustNum": 2, "Name": "FlyByNight", "NewCust": true }
  ]
}