Gets the JsonObject value of the named property.

Return type: Progress.Json.ObjectModel.JsonObject class

Access: PUBLIC

Applies to: Progress.Json.ObjectModel.JsonObject class

Syntax

GetJsonObject( INPUT property-name AS CHARACTER )
property-name
A CHARACTER expression that indicates the name the property value to be retrieved from the JsonObject.

property-name is case-sensitive.

A JsonError is raised if:

  • property-name is the empty string (""), or is the Unknown value (?)
  • The property does not exist
  • The property value is not a JsonObject

The following example demonstrates the functionality of the GetJSonObject() method.

The following is a sample JsonObject:

{
  "CustOrder": {
    "CustNum": 3000,
    "Name": "Lift Tours",
    "NewCust": false,
    "Order": {"OrderNum": 82, "OrderDate": "2024-09-20"}
  }
}

The following example code uses the GetJsonObject() method to extract the Order JSON data:

USING PROGRESS.Json.ObjectModel.*.

DEFINE VARIABLE CustInfo AS LONGCHAR NO-UNDO.
DEFINE VARIABLE myObj AS JsonObject NO-UNDO.
DEFINE VARIABLE myOrderObj AS JsonObject NO-UNDO.
DEFINE VARIABLE myParser AS ObjectModelParser NO-UNDO.
DEFINE VARIABLE myLongchar as LONGCHAR NO-UNDO.

/* Set CustInfo to the JsonObject shown above. */

FIX-CODEPAGE (CustInfo) = "UTF-8".

COPY-LOB FROM FILE "CustOrder.json" TO CustInfo.

myParser = NEW ObjectModelParser(). 

myObj = CAST(myParser:Parse(CustInfo), JsonObject).
myOrderObj = myObj:GetJsonObject("CustOrder"):GetJsonObject("Order").
myOrderObj:Write(myLongchar, TRUE).

MESSAGE STRING(myLongchar)
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

The following is the resulting myLongchar value:

{
  "OrderNum": 82,
  "OrderDate": "2024-09-20"
}