{ TTestDecorated }
(*
a simple object decorated with a custom name to be used when serializing and
deserializing, as well as some simple typed properties to include in
serialization
*)
[JsonObject('myTestObject')]
TTestDecorated = class(TObject)
private
FTest : String;
FTestInt : Integer;
published
[JsonProperty('test')]
property Test : String read FTest write FTest;
[JsonProperty('testInteger')]
property TestInt : Integer read FTestInt write FTestInt;
end;
...
procedure TestSimple;
var
LTest : TTestDecorated;
LJSON,
LError : String;
begin
//setting a value on our test
LTest := TTestDecorated.Create;
LTest.Test := 'a test';
//calling serialize
if not (EZSerialize<TTestDecorated>(LTest, LJSON, LError)) then
raise Exception.Create(LError) //failed to serialize
else
WriteLn(LJSON); //success
end;