title: How to count number of elements in a JSON array in Delphi
body: <p>I am accessing a TJSONValue in Delphi(using REST components and Google Books' API). I want to know how many elements are in the array: 'items'.
  This is the format of the JSONValue:</p>
  
  <blockquote>
  <pre><code>   "kind": "books#volumes",
     "totalItems": 221,
     "items": [
         {...},
         {...},
         {...}]
  </code></pre>
  </blockquote>
  
  <p>Note* "totalItems" does not refer to the size of the array.</p>
  
  <p>I've tried somethin along this line, but it raises a conversion error.</p>
  
  <pre><code>var
     JSONBook: TJSONValue;
     CountItems: integer;
  begin
     JSONBook := RESTResponse1.JSONValue;
  
     ShowMessage(IntToStr(JSONBook.GetValue&lt;string&gt;('items').Length));
     CountItems := JSONBook.GetValue&lt;string&gt;('items').Length;
  
     for i := 0 to CountItems-1 do
     begin
       ...
     end;
  end;
  </code></pre>