Try OpenEdge Now
skip to main content
ABL Reference
Class Properties and Methods Reference : Read( ) method (JsonArray)
 

Read( ) method (JsonArray)

Uses the contents of a temp-table to generate a JsonArray. The current contents of the JsonArray are removed.
Return type: LOGICAL
Access: PUBLIC
Applies to: Progress.Json.ObjectModel.JsonArray class

Syntax

Read( INPUT TABLE-HANDLE tt-handle )

Read( INPUT TABLE-HANDLE tt-handle,
      INPUT omit-initial-values AS LOGICAL )
tt-handle
Represents a handle to either a static temp-table or dynamic temp-table to be used as the source for setting the JsonArray. Each element in this JsonArray is a JsonObject representing a row in the temp-table. If this value is the Unknown value (?), a JsonError is raised.
omit-initial-values
An LOGICAL expression where:
*TRUE directs the AVM to exclude temp-table fields containing their initial values from the JSON object.
*FALSE directs the AVM to include all temp-table field data in the JSON. The default value of the expression is FALSE. If you specify the Unknown value (?), the method uses the default value of FALSE.
When working with large temp-tables, omitting fields containing their initial values can yield smaller JSON values, more efficient network transfers, and performance gains with the Read( ) method.
This behavior applies both to temp-table fields which have the default initial value for its data type, and for fields which have an initial value set with the ABL INITIAL option.
The ABL READ-JSON( ) method always populates created records with initial values from the temp-table or ProDataSet definition. Other applications might not do this.
When a temp-table handle is passed to JsonArray:Read( ), the JsonArray is set to a series of objects representing each row in the temp table. The following is a temp-table definition that is passed to JsonArray:Read( ):
DEFINE VARIABLE httCust AS HANDLE NO-UNDO.
DEFINE VARIABLE myArr AS JsonArray 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-tables
.
*/

httCust = TEMP-TABLE ttCust:HANDLE.
myArr = NEW JsonArray().
myArr:Read(TABLE-HANDLE httCust).
myArr:Write(myLongchar, TRUE).
The following is the resultant JSON construct tree, myLongchar:
[
  {"CustNum": 1, "Name": "Lift Tours", "NewCust": false },
  {"CustNum": 2, "Name": "FlyByNight", "NewCust": true }
]