I'm having trouble reading a JSON that has a extent[6] data property.
This is the JSON:
{
"SalesRep": [
{
"SalesRep": "BBB",
"RepName": "Brawn , Bubba B.",
"Region": "East",
"MonthQuota": [
1600,1648,1697,1748,1800,1854
]
}
]
}
I want to read the second numerical value (extent[2]=1648).
This is my pgm:
myParser = NEW ObjectModelParser( ).
myConstruct = myParser:ParseFile("JsonRaro.json").
myJsonObj2 = CAST(myJsonObj1:GetJsonArray("ttSalesRep"):GetJsonObject(1),JsonObject).
MESSAGE
"2 " STRING( myJsonObj2:GetJsonText("RepName") ) SKIP /*result="2 Brawn , Bubba B."*/
"3 " STRING( myJsonObj2:GetJsonText("MonthQuota") ) SKIP /*result="
[1600,1648,1697,1748,1800,1854]"*/
"3a " STRING( myJsonObj2:GetJsonArray("MonthQuota"):GetJsonArray(2,1) ) SKIP /*ERROR*/
VIEW-AS ALERT-BOX.
You only need to get the item from the array, not another array.
So this
"3a " STRING( myJsonObj2:GetJsonArray("MonthQuota"):GetJsonArray(2,1) )
should be
"3a " STRING( myJsonObj2:GetJsonArray("MonthQuota"):GetInteger(2) )