-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support stringifying simple getter methods for classes
- Loading branch information
1 parent
cdcc279
commit 55eca20
Showing
3 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
type | ||
TSubTest = class | ||
private | ||
FSub : TSubTest; | ||
FName : String; | ||
function GetSub : TSubTest; begin Result := FSub; end; | ||
|
||
published | ||
property Name : String read ('<' + FName + '>') write FName; | ||
property Sub : TSubtest read GetSub write FSub; | ||
end; | ||
|
||
type | ||
TTest = class | ||
protected | ||
function GetStr : String; begin Result := 'hello'; end; | ||
|
||
published | ||
property Str : String read GetStr; | ||
property Int : Integer read (123); | ||
property Bool : Boolean read (1 <> 0); | ||
property Num : Float read (3.14); | ||
property Arr : array of String read (StrSplit('abc,de', ',')); | ||
property Sub : TSubTest; | ||
end; | ||
|
||
var i := new TTest; | ||
i.Sub := new TSubTest; | ||
i.Sub.Name := 'hello'; | ||
i.Sub.Sub := new TSubTest; | ||
i.Sub.Sub.Name := 'world'; | ||
|
||
|
||
PrintLn(JSON.PrettyStringify(i)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"Arr" : [ | ||
"abc", | ||
"de" | ||
], | ||
"Bool" : true, | ||
"Int" : 123, | ||
"Num" : 3.14, | ||
"Str" : "hello", | ||
"Sub" : { | ||
"Name" : "<hello>", | ||
"Sub" : { | ||
"Name" : "<world>", | ||
"Sub" : null | ||
} | ||
} | ||
} |