From Clomosy Docs

No edit summary
No edit summary
Line 13: Line 13:
  var
  var
   qry:TCLJSONQuery;
   qry:TCLJSONQuery;
  jsonStr:string;
  begin
  begin
     try
     try

Revision as of 08:26, 12 September 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}]');
     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;