[Stackoverflow] [Progress OpenEdge ABL] How can I differentiate an Array of integer values vs an Array of Object

Status
Not open for further replies.
S

SSosa

Guest
Problem: How can I differentiate the properties "MonthQuota" and "Forecast"?

In my real program Im using JsonObject class and dynamic ProDataSet and it's a recursive parse program. Take on consideration thos points for any suggestions.

I am trying to parse a JSON that contains a property ("MonthQuota") with an array of numerical values and another second property ("Forcast") with an array of Objects.
This es the JSON:

Code:
{  
        "ttSalesRep": [  
            {  
                "SalesRep": "BBB",  
                "RepName": "Brawn, Bubba B.",  
                "Region": "East",  
                "MonthQuota": [  
                    1600,1648,1697,1748,1800,1854  
                ],  
                "Forcast": [  
                    {
                        "Month1": "Enero",  
                        "Amont1": 111.1  
                    },  
                    {  
                      "Month1": "Marzo",  
                      "Amont1": 111.2  
                    }  
                ]  
            }  
        ]  
    }

Because I must parse the two properties in different ways, I tried using the GetType method. But I have the same result for "MonthQuota" and "Forcast" property: GetType = 5. This is a small program that shows my problem:

Code:
DEFINE VARIABLE myParser     AS ObjectModelParser NO-UNDO.  
DEFINE VARIABLE myConstruct  AS JsonConstruct     NO-UNDO.  
DEFINE VARIABLE myJsonObj    AS JsonObject        NO-UNDO.  
DEFINE VARIABLE myArray      AS CHAR EXTENT       NO-UNDO.  
DEFINE VARIABLE my_JSON_File AS CHARACTER         NO-UNDO.  
  
  
my_JSON_File = "myJsonFile.json".  
  
myParser    = NEW ObjectModelParser().  
myConstruct = myParser:ParseFile(my_JSON_File).  
myJsonObj   = CAST(myConstruct, JsonObject).  
  
myArray = myJsonObj:GetJsonArray("ttSalesRep"):GetJsonObject(1):GetNames().  
MESSAGE  
    myArray[4] "=" myJsonObj:GetJsonArray("ttSalesRep"):GetJsonObject(1):GetType(myArray[4]) SKIP  
    myArray[5] "=" myJsonObj:GetJsonArray("ttSalesRep"):GetJsonObject(1):GetType(myArray[5]) SKIP  
VIEW-AS ALERT-BOX.

Continue reading...
 
Status
Not open for further replies.
Top