I have a json file
I want read total_pages
Name DataType Subtype Length
JToken DotNet Newtonsoft.Json.Linq.JToken.'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
ItemList DotNet Newtonsoft.Json.Linq.JArray.'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
Item DotNet Newtonsoft.Json.Linq.JObject.'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
result := HttpResponseMessage.Content.ReadAsStringAsync.Result;
i :=0;
JToken := JToken.Parse(result);
ItemList := JToken.SelectToken('pagination');
FOREACH Item IN ItemList DO BEGIN
i :=i+1;
IF i=3 THEN BEGIN
MESSAGE(Item.GetValue('total_pages').ToString);
EVALUATE(TotalPage,Item.GetValue('total_pages').ToString);
END;
END;
But Error in Item.GetValue('total_pages').ToString
Whats wrong ?
Answers
And why do you loop through the elements? I think the memberlist of a json object is unordered, so you should not assume that the third element is the "total_pages" element.