Using GetType

Posted by goo on 07-Jan-2020 14:32

11.7

Where or how do I find the name of GetType? If i do jsonObject:GetType('myJsonField') I will get a number refering to what type it has. How do I get the name?

All Replies

Posted by Fernando Souza on 07-Jan-2020 14:41

Did you look at the documentation for GetType() ? It reads "The returned integer corresponds to the static integer properties defined in the Progress.Json.ObjectModel.JsonDataType class". So you can use that to generate the name.

Posted by Peter Judge on 07-Jan-2020 14:44

You can't really with the built-in.
 
You can do
 
CASE jsonObject:GetType('myJsonField'):
    WHEN Progress.Json.ObjectModel.JsonDataType:STRING THEN …
    WHEN Progress.Json.ObjectModel.JsonDataType:NULL  THEN …
    WHEN Progress.Json.ObjectModel.JsonDataType:OBJECT THEN …
    WHEN Progress.Json.ObjectModel.JsonDataType:ARRAY THEN …
    WHEN Progress.Json.ObjectModel.JsonDataType:BOOLEAN  THEN …
    WHEN Progress.Json.ObjectModel.JsonDataType:NUMERIC  THEN …
END CASE.
 
 
There's a 'wrapper' enum called OpenEdge.Core.JsonDataTypeEnum that mirrors those integer values. Using that you can do
 
Def var typeName as char.
typeName = string(
                OpenEdge.Core.JsonDataTypeEnum:GetEnum(jsonObject:GetType('myJsonField'))               
)
 
HTH,
-- peter
 
 
 
 

Posted by goo on 07-Jan-2020 14:54

Aah, that was what I was looking for!! Thanks !
 

This thread is closed