I donโt think this will work, I suppose you need Delphi units to use FireDacJsonreflect.
You can infer Json yourself, see this little example. I use comany from the DB example only 3 fields in clientdataset, you will probably make it a little more complicated, and also another constructor, I think
Just an idea ..
function TServerMethods1.JsonDB: TJSONObject; // Hold the array var i : Integer; JsonArray: TJSONArray; record_number : Integer; begin result:=TJSONObject.Create; // Field names JsonArray:=TJSONArray.Create; ClientDataSet1.First; for i := 0 to ClientDataSet1.Fields.Count-1 do Begin JsonArray.AddElement(TJSONObject.Create(TJSONPair.Create('Field'+I.ToString ,ClientDataSet1.Fields[i].FieldName))); End; Result.AddPair('Fields',JsonArray); //Data record_number:=0; while not ClientDataSet1.Eof do Begin inc(record_number); JsonArray:=TJSONArray.Create; for i := 0 to ClientDataSet1.Fields.Count-1 do Begin JsonArray.AddElement(TJSONObject.Create(TJSONPair.Create(I.ToString,ClientD ataSet1.Fields[i].Asstring))); End; Result.AddPair('record-'+record_number.ToString,JsonArray); ClientDataSet1.Next; End; end;
This should give a result, for example
{"result": [{"Fields": [{"Field0": "CustNo"}, {"Field1": "Company"}, {"Field2": "Country"}], "record-1": [ {"0": "1221"}, {"1": "Kauai Dive Shoppe"}, {"2": "US"}], "record-2": [{"0": "1231"}, {"1": "Unisco"}, {"2": "Bahamas"}], "record-3": [{"0": "1351"}, {"1": "Sight Diver"}, { "2": "Cyprus"}], "record-4": [{"0": "1354"}, {"1": "Cayman Divers World Unlimited"}, {"2": "British West Indies "}]," record-5 ": [{" "0": "1356"}, {"1": "Tom Sawyer Diving Center"}, {"2": "US Virgin Islands}}, record-6 ": [{" 0 ":" 1380 "}, {" 1 ":" The center of the blue jack aqua "}, {" 2 ":" US "}]," record-7 ": [{" 0 ": "1384"}, {"1": "VIP Divers Club"}, {"2": "US Virgin Islands}}]," record-8 ": [{" 0 ":" 1510 "}, {" 1 ":" Ocean Paradise "}, {" 2 ":" US "}]," record-9 ": [{" 0 ":" 1513 "}, {" 1 ":" Fantastique Aquatica "}, {" 2 ": Columbia}], "record-10": [{"0": "1551"}, {"1": "Marmot Diving Club"}, {"2": "Canada"}], "record-11 ": [{" 0 ":" 1560 "}, {" 1 ":" Depth Charge "}, {" 2 ":" US "}]," record-12 ": [{" 0 ":" 1563 " }, {"1": "Blue Sport"}, {"2": "US"}], "record-13": [{"0": "1624"}, {"1": "Makai SCUBA Club "}, {" 2 ":" US "}]," record-14 ": [{" 0 ":" 1645 "}, {" 1 ":" Action Club "}, {" 2 ":" US " }], "record-15": [{"0": "1651"}, {"1": "Jamaica's SCUBA Center"}, {"2": "West Indies"}], "record-16" : [{"0": "1680"}, {"1": "Island Finders"}, {"2": "US"}], "record-17": [{"0": "1984"} , {"1": "Underwater Adventure"}