I'm creating a VCL Application with Delpi 10.3 and want to support some web functionality by having the user enter the ISBN of a book into a TEdit component and from there passing/sending this value to a search field on this website: https://isbnsearch.org after which the website looks up the ISBN and displays the Author of the book. I want to somehow access the information (i.e Author) presented by the search result and again use it in my application.
This …
我正在 Delphi 中访问 TJSONValue(使用 REST 组件和 Google Books 的 API)。我想知道数组中有多少元素:'items'。这是 JSONValue 的格式:
Run Code Online (Sandbox Code Playgroud)"kind": "books#volumes", "totalItems": 221, "items": [ {...}, {...}, {...}]
注意*“totalItems”不是指数组的大小。
我已经沿着这条线尝试了一些东西,但它引发了一个转换错误。
var
JSONBook: TJSONValue;
CountItems: integer;
begin
JSONBook := RESTResponse1.JSONValue;
ShowMessage(IntToStr(JSONBook.GetValue<string>('items').Length));
CountItems := JSONBook.GetValue<string>('items').Length;
for i := 0 to CountItems-1 do
begin
...
end;
end;
Run Code Online (Sandbox Code Playgroud)