From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 17: | Line 17: | ||
qry := TCLJSONQuery.Create(nil); | qry := TCLJSONQuery.Create(nil); | ||
qry := Clomosy.ClDataSetFromJSON('[{"name":"Anna","age":20},{"name":"David","age":27}]'); | qry := Clomosy.ClDataSetFromJSON('[{"name":"Anna","age":20},{"name":"David","age":27}]'); | ||
//ShowMessage(qry.getJSONString); | |||
with qry do | with qry do | ||
begin | begin | ||
Revision as of 13:15, 14 November 2023
It is used to convert JSON data into a TCLJSONQuery object and process the data by performing operations on it. Let's take a look at how it can be used:
A variable belonging to the TCLJSONQuery object is declared. Then, this object is created.
var qry:TCLJSONQuery;
qry := TCLJSONQuery.Create(nil);
JSON data is transformed into a TCLJSONQuery object. This object contains the JSON data and allows query operations to be performed on it. Following this, operations can be performed on this data.
Example:
var
qry:TCLJSONQuery;
begin
try
qry := TCLJSONQuery.Create(nil);
qry := Clomosy.ClDataSetFromJSON('[{"name":"Anna","age":20},{"name":"David","age":27}]');
//ShowMessage(qry.getJSONString);
with qry do
begin
if Found then
begin
First;
while not EOF do
begin
ShowMessage(FieldByName('name').AsString);
Next;
end;
end;
end;
except
ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
end;
end;