IMPORT util MAIN DEFINE s STRING DEFINE mycatch RECORD --Value DYNAMIC ARRAY of util.JSONObject, Value DYNAMIC ARRAY OF RECORD DomainId INTEGER, DomainName STRING, Description STRING, WebTitle STRING, ImageUrl STRING, EditButtonsOn BOOLEAN, MapServiceId INTEGER, MobileMapCacheId INTEGER END RECORD, Status STRING, Message STRING, ErrorMessages DYNAMIC ARRAY OF STRING, WarningMessages DYNAMIC ARRAY OF STRING, SuccessMessages DYNAMIC ARRAY OF String END RECORD LET s = '{"Value":[{"DomainId":23,"DomainName":"PU","Description":"Public Utilities","WebTitle":"","ImageUrl":"","EditButtonsOn":false,"MapServiceId":1,"MobileMapCacheId":0},{"DomainId":21,"DomainName":"PW","Description":"Public Works","WebTitle":"","ImageUrl":"","EditButtonsOn":false,"MapServiceId":2,"MobileMapCacheId":0}],"Status":0,"Message":null,"ErrorMessages":[],"WarningMessages":[],"SuccessMessages":[]}' CALL util.JSON.parse(s, mycatch) DISPLAY util.JSON.format(util.JSON.stringify(mycatch)) DISPLAY mycatch.value.search("DomainName","PU") END MAIN
sf@toro:/tmp$ fglcomp -M search.4gl && fglrun search.42msearch.4gl:33:25:33:27:error:(-8447) function 'get' not found in type 'base.Array'.search.4gl:33:62:33:64:error:(-8447) function 'get' not found in type 'base.Array'.
IMPORT utilMAIN DEFINE s STRING DEFINE mycatch RECORD Value DYNAMIC ARRAY OF RECORD DomainId INT, DomainName STRING, Description STRING --...etc END RECORD END RECORD LET s='{"Value":[{"DomainId":23,"DomainName":"PU","Description":"Public Utilities","WebTitle":"","ImageUrl":"","EditButtonsOn":false,"MapServiceId":1,"MobileMapCacheId":0},{"DomainId":21,"DomainName":"PW","Description":"Public Works","WebTitle":"","ImageUrl":"","EditButtonsOn":false,"MapServiceId":2,"MobileMapCacheId":0}],"Status":0,"Message":null,"ErrorMessages":[],"WarningMessages":[],"SuccessMessages":[]}' CALL util.JSON.parse(s,mycatch) DISPLAY mycatch.Value.search("DomainName","PU")END MAIN
DISPLAY util.JSON.proposeType(s)
RECORD Value DYNAMIC ARRAY OF RECORD DomainId FLOAT, DomainName STRING, Description STRING, WebTitle STRING, ImageUrl STRING, EditButtonsOn BOOLEAN, MapServiceId FLOAT, MobileMapCacheId FLOAT END RECORD, Status FLOAT, Message STRING, ErrorMessages DYNAMIC ARRAY OF STRING, WarningMessages DYNAMIC ARRAY OF STRING, SuccessMessages DYNAMIC ARRAY OF STRINGEND RECORD
MAIN DEFINE c1, c2 base.Channel DEFINE a DYNAMIC ARRAY OF base.Channel LET c1 = base.Channel.create() LET c2 = base.Channel.create() LET a[1] = NULL LET a[2] = c1 LET a[3] = NULL LET a[4] = c2 DISPLAY a.search("", c1) DISPLAY a.search("", c2) DISPLAY a.search("", "foo")END MAIN
$ fglcomp ch.4gl && fglrun ch.42m 2 4 0
DISPLAY a.search("xxxxxx", c1)