You are not logged in.
Pages: 1
I try to test ObjectToJSON function from TCollection object.
No JSON content generate from that object.
Then I track down to TJSONSerializer.WriteObject.
tkClass: begin
Obj := pointer(GetOrdProp(Value,pointer(P))); // works also for CPU64
if IsTSQLRecord then begin
if not P^.PropType^^.ClassType.InheritsFrom(TSQLRecordMany) then begin
HR(P);
Add(PtrInt(Obj));
end;
end else
if Obj<>nil then begin
HR(P);
if Obj.InheritsFrom(TCollection) then begin
HR;
...
...
Obj := pointer(GetOrdProp(Value,pointer(P))); // works also for CPU64
Always return nil to Obj. No JSON content generated
I plan to implement server service that accept new object as parameter and process in server memory.
The formation is...
-Client call server function that accept some object as parameter [AFunction(obj: TSampleRecord)]
-Server decode json object to TSampleRecord
-Server process something with object(TSampleRecord) then save object to database and return result
Could you show some example code to guidance me?
thanks
Now I get the latest version in repository. It's work like charm. The mapping is table per concrete class.
I can use it now in my little project
To implement custom logic on server, and use JSON serialization, you've already server-side RESTful services features included in the framework.
If you recommended this method I will try it
I have some question about this method, I will post in new topic for easy to find
1.13? really? Can't wait to see it!!!
I really like this framework. It's ORM, Testable, JSON, Http, Fast, Smart etc.
Could you add some sample to show how to implement custom logic on http server when receiving JSON object?
I plan to inherit TSQLite3HttpServer and override Request function.
But the code is too complicate for me to decode
Maybe I doing some mistake. I extend "HTTP Client-Server" sample.
My class model is..
TSQLSampleRecord = class(TSQLRecord)
private
fName: RawUTF8;
fQuestion: RawUTF8;
fTime: TDateTime;
published
property Name: RawUTF8 read fName write fName;
property Question: RawUTF8 read fQuestion write fQuestion;
property Time: TDateTime read fTime write fTime;
end;
TSQLInherited = class(TSQLSampleRecord)
private
FValue: Integer;
published
property Value: Integer read FValue write FValue;
end;
Then... CreateSampleModel
function CreateSampleModel: TSQLModel;
begin
result := TSQLModel.Create([TSQLSampleRecord, TSQLInherited]);
end;
On client side....
procedure TForm1.InheritedButtonClick(Sender: TObject);
var Rec: TSQLInherited;
begin
Rec := TSQLInherited.Create;
try
Rec.Time := Now;
// we use explicit StringToUTF8() for conversion below
// a real application should use TLanguageFile.StringToUTF8() in SQLite3i18n
Rec.Name := StringToUTF8(NameEdit.Text);
Rec.Question := StringToUTF8(QuestionMemo.Text);
Rec.Value := Random(100);
if Database.Add(Rec,true)=0 then
ShowMessage('Error adding the data') else begin
NameEdit.Text := '';
QuestionMemo.Text := '';
NameEdit.SetFocus;
end;
finally
Rec.Free;
end;
end;
The data saved to Inherited table with 1 property(Value), Other property is missing
Hard to believe no one ask these question.
Is this framework support "Object Inheritance Mapping" ?
How? or When?
Pages: 1