I would like to deserialize JSON from a REST call into an array and I'm not sure of the exact syntax. Are there any examples you can point me to or can you provide the syntax? I am working with Visual COBOL 2.2 and Visual Studio 2013. Thanks!
This is what I have so far:
$set sourceformat(variable)
$set ilusing "System.Net"
$set ilusing "Newtonsoft.Json"
$set ilusing "System.Configuration"
$set ilusing "System.Collections.Specialized"
class-id CallRestService implements type IDisposable.
working-storage section.
01 wc type WebClient value new WebClient().
method-id RestService.
local-storage section.
procedure division.
try
declare modelResult as object
declare url as string
set wc::UseDefaultCredentials to true;
set wc::Headers[type HttpRequestHeader::ContentType] to "application/json"
set serializedResult to wc::DownloadString(url) *> Assume that url has been set to the appropriate route
set modelResult to type JsonConvert::DeserializeObject(serializedResult) *> This is where I'm not sure how to put the result into an array
catch ex as type Exception
set serializedResult to ex
end-try
goback.
end method.
method-id Dispose public.
local-storage section.
procedure division.
goback.
end method.
end class.