Previous Next

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:
Access:
Applies to:
 
Syntax 
Read( INPUT DATASET-HANDLE pds-handle )
 
Read( INPUT DATASET-HANDLE pds-handle,
      INPUT omit-initial-values 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
An LOGICAL expression where TRUE directs the AVM to exclude temp-table fields containing their initial values from the JSON string, 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. The following is a temp-table definition that is 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 }
  ]
]
 

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.