Previous Next

GetJsonObject( ) method (JsonObject)
Gets the JsonObject value of the named property.
Return type:
Access:
Applies to:
 
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.
A JsonError is raised if:
*
property-name is the empty string (""), or is the Unkown value (?)
*
*
The following example demonstrates the functionality of the GetJSonObject( ) method.
The following is a sample JsonObject:
 
{
  “CustOrder”: {
    “CustNum”: 1,
    “Name”: “Lift Tours”,
    “NewCust”: false,
    “Order”: {“OrderNum”: 82, “OrderDate”: “2010-09-20”}
    ]
  }
}
 
The following code fragment uses the GetJsonObject( ) method:
DEFINE VARIABLE CustInfo AS LONGCHAR NO-UNDO.
DEFINE VARIABLE myObj AS JsonObject NO-UNDO.
DEFINE VARIABLE myOrderObj AS JsonObject NO-UNDO.
DEFINE VARIABLE myLongchar as LONGCHAR NO-UNDO.
 
/*
 .
 . Set CustInfo to the JsonObjet shown above.
 .
 */
 
myObj = CAST(myParser:Parse(CustInfo), JsonObject).
myOrderObj = myObj:GetJsonObject(“CustOrder”):GetJsonObject(“Order”).
myOrderObject:Write(myLongchar, TRUE).
The following is the resulting myLongchar value:
 
{“OrderNum”: 82, “OrderDate”: “2010-09-20”}

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