Query(Path: String): IJsonArray;
Path. JSONPath query to get child elements.
The Query method returns the array of elements obtained by executing a JSONPath query.
When creating various conditions in a query take into account the specified data type. Implicit type conversion is not supported. Information about creating a JSONPath query can be found in specialized documentation, for example, MSDN.
Executing the example requires the JSON file: d:\Work\Json\data.json. The file has the following approximate structure:
Sub UserProc;
Var
Doc: IJsonDocument;
JSONArray: IJsonArray;
Begin
Doc := New JsonDocument.Create;
Doc.ReadFromFile("d:\Work\Json\data.json");
JSONArray := Doc.RootElement.Query("$.product[?(@.price > 50 && @.price < 350)]");
Debug.WriteLine("Number of selected elements: " + JSONArray.Count.ToString);
End Sub UserProc;
After executing the example, the JSON structure will be read from the file. This structure will be requested to select elements according to the specified condition. The number of selected elements will be displayed in the development environment console.
See also: