P
Peter Judge
Guest
When using JSON objects in ABL I can work with property names in a couple of ways - jsonData:GetNames(output arrayOfNames) and loop through them one at a time. - jsonData:Has("string name") and jsonData:Get*("string name"). Assuming I know the property I want , what good strategies do I have for reducing errors in the names? - I can just use a string "ioMode" which I repeat through the code. Not great since it's very error prone to typos and case-sensitivity issues - I can add a static private property (or variable or preprocessor) which holds the name DEF PRIVATE STATIC PROPERTY IO_MODE_PROP_NAME AS CHAR INIT 'ioMode' GET. - It strikes me as I type this that I can use an enum too ENUM PropertyNamesEnum: DEF ENUM ioMode. END ENUM and do something like jsonData:Has(string(PropertyNamesEnum:ioMode)) - anything else that I'm missing? Any other approaches that you use? JSON example "/Employee": { "GET": { "contentType": "application/json", "jsdo": { "entityName": "doh.EmployeeBE", "function": "readData", "operation": "read", "schema": "dsEmployee" }, "entity": { "name": "doh.EmployeeBE", "function": "readData", "arg": [ { "ablName": "pcFilter", "ioMode": "INPUT", "ablType": "Character", "msgElem": {"type": "QUERY", "name": "filter"} }, { "ablName": "dsEmployee", "ablType": "dataset", "ioMode": "OUTPUT", "msgElem": [{"type": "BODY","name": null}] },
Continue reading...
Continue reading...