From Clomosy Docs
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:
- Base Syntax
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;
- TRObject Syntax
var
qry:TCLJSONQuery;
{
try
{
qry = TCLJSONQuery.Create(nil);
qry = Clomosy.ClDataSetFromJSON('[{"name":"Anna","age":20},{"name":"David","age":27}]');
//ShowMessage(qry.getJSONString);
with qry do
{
if (Found)
{
First;
while (not EOF)
{
ShowMessage(FieldByName('name').AsString);
Next;
}
}
}
}
except
{
ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
}
}