Jump to content

Dmitriy M

  • Content Count

  • Joined

  • Last visited

Community Reputation

2 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.2 Tokyo
  1. Dmitriy M

    paste into watch list

    Another non-obvious trick is that you can drag&drop selected identifier/expression (double click to select) into the watch list.
  2. Dmitriy M

    JSON - Why self ins't updated with new values ?

    program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, REST.JSON, Unit1 in 'Unit1.pas'; var Person1, Person2: TPerson; jsonstr: string; begin Person1 := TPerson.Create; try Person1.Name := 'Hello'; jsonstr := Person1.SaveSettings; writeln(jsonstr); //write {"name":"Hello"} Person1.Name := 'hi'; Person1.LoadSettings(jsonstr); writeln(Person1.Name); //write Hello readln; finally Person1.Free; end; jsonstr := '{"name":"Stephane"}'; Person2 := TPerson.FromString(jsonstr); try writeln(Person2.Name); //write Stephane readln; finally Person2.Free; end; end. unit Unit1; interface type TPerson = class(TObject) private [JSONNameAttribute('NAME')] FName: string; public class function FromString(const aJsonString: String): TPerson; procedure LoadSettings(const aJsonString: String); function SaveSettings: string; property Name: string read FName write FName; end; implementation uses REST.JSON; class function TPerson.FromString(const aJsonString: String): TPerson; begin Result := TJSON.JsonToObject<TPerson>(aJsonString); end; procedure TPerson.LoadSettings(const aJsonString: String); var oJSON: TJSONObject; begin oJSON := TJSONObject.ParseJSONValue(aJsonString) as TJSONObject; try TJSON.JsonToObject(self, oJSON); finally oJSON.Free; end; end; function TPerson.SaveSettings: String; begin Result := TJSON.ObjectToJsonString(self); end; end. Reference
  3. Dmitriy M

    Maintaining For loop(s)

    Take a look at FireDAC Local SQL engine. You can populate FDMemTable with data stored in your TProject records and run plain SQL queries against this dataset.