Hi
Not sure if this belongs here or the BDL section but, I am trying to work with a restful web service from a carrier integration firm and I am struggling to manage their return results and am looking for some advice. Their documentation states:
The response has 2 entries: one is a dictionary for errors and one a list of successful imports.
Here are two examples of the response, the first is a successful call and the second an unsuccessful one:
{"errors":{},"success":["000014298"]}
{"errors":{"0":["identifier: Consignment with identifier already exists"]},"success":[]}
In BDL, I am struggling to handle the dictionary element. Here is a snippet of my code:
define responseR record
errors dictionary of string,
success dynamic array of string
end record,
keys dynamic array of string,
idx smallint
.
.
.
let info.status = resp.getStatusCode()
if info.status = 200 then
let info.response = resp.getTextResponse()
call util.JSON.parse(info.response, responseR)
let keys = responseR.errors.getKeys()
for idx = 1 to keys.getLength()
display responseR.errors[keys[idx]]
end for
for idx = 1 to responseR.success.getLength()
display responseR.success[idx]
end for
end if
In the event that the errors dictionary has any entries, I get a BDL error:
JSON parse error: Unexpected '[', target is not an ARRAY
I can see it is not, but what is the best construct to parse such a return value into?
Thanks
Gary