Try OpenEdge Now
skip to main content
Working with JSON
Reading and Serializing JSON to/from ProDataSets and Temp-tables : Writing JSON from a temp-table, temp-table buffer, or a ProDataSet : Minimizing the size of JSON data : Omitting the outer object in JSON data
 
Omitting the outer object in JSON data
When writing JSON data using the WRITE-JSON( ) method, an optional LOGICAL expression, omit-outer-object, indicates whether the outer-most object is included in the JSON output. TRUE directs the AVM to remove the outer-most object on output, and FALSE directs the AVM to include the outer-most object in the output.
When writing a JSON string or JsonObject target, the default value is FALSE. If you specify the Unknown value (?), WRITE-JSON( ) also uses the default value of FALSE. When writing a temp-table to a JsonObject target, omit-outer-object must be FALSE. If you specify TRUE, WRITE-JSON( ) generates an error message and returns FALSE.
When writing a JsonArray target, the default value is TRUE. If you specify the Unknown value (?), WRITE-JSON( ) also uses the default value of TRUE. When writing a temp-table or temp-table buffer object to a JsonArray target, omit-outer-object must be TRUE. If you specify FALSE, WRITE-JSON( ) generates an error message and returns FALSE.
The following examples demonstrate the difference between the value of TRUE and FALSE for omit-outer-object when writing a JSON string on a temp-table or temp-table buffer object handle.
{"tt": [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
]}
The above values are generated when the omit-outer-object is FALSE.
[
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 23}
]
The above values are generated when the omit-outer-object is TRUE.
The following examples demonstrates the difference between the value of TRUE and FALSE for omit-outer-object when writing a JSON string on a ProDataSet object handle.
{"pds" : {
"tt1" : [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
],
"tt2": [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
],
"tt3": [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
]
}}
The above values are generated when the omit-outer-object is FALSE.
{
"tt1": [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
],
"tt2": [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
],
"tt3": [
{"f1": 11, "f2": 12, "f3": 13},
{"f1": 21, "f2": 22, "f3": 23},
{"f1": 31, "f2": 32, "f3": 33}
]
}
For the same ProDataSet, the above values are generated when the omit-outer-object is TRUE.