if not Response.IsSuccessStatusCode then
Error('Invalid Response');
Response.Content.ReadAs(ResponseText);
if not JToken.ReadFrom(ResponseText) then
Error('Invalid Response');
JsonMgt.InitializeCollection(ResponseText);
for Counter := 0 to JsonMgt.GetCollectionCount() - 1 do begin
JsonMgt.GetObjectFromCollectionByIndex(returntext, Counter);
JToken.ReadFrom(returntext);
JToken.SelectToken('address.street', resultToken);
Message(resultToken.AsValue().AsText());
end;
end;
Answers
You could take a look to this post:
https://forum.mibuso.com/discussion/comment/330760
Regards
Thank you.
var
JsonMgt: Codeunit "JSON Management";
Counter: Integer;
JArray: JsonArray;
Jobject: JsonObject;
JToken: JsonToken;
resultToken: JsonToken;
OutputText: Text;
ResponseText: Text;
returntext: Text;
returntext2: Text;
url: text;
begin
url := 'https://jsonplaceholder.typicode.com/users';
HttpClient.Get(url, Response);
if not Response.IsSuccessStatusCode then
Error('Invalid Response');
Response.Content.ReadAs(ResponseText);
if not JToken.ReadFrom(ResponseText) then
Error('Invalid Response');
JsonMgt.InitializeCollection(ResponseText);
for Counter := 0 to JsonMgt.GetCollectionCount() - 1 do begin
JsonMgt.GetObjectFromCollectionByIndex(returntext, Counter);
JToken.ReadFrom(returntext);
JToken.SelectToken('address.street', resultToken);
Message(resultToken.AsValue().AsText());
end;
end;