Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error to Parse #15

Open
wants to merge 203 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
cee8821
Upgrade to 1.0
JensBorrisholt Dec 20, 2019
d9b9331
Update README.md
JensBorrisholt Dec 20, 2019
c751921
Added missing Pkg.Json.DTO;
JensBorrisholt Dec 20, 2019
9078036
Merge branch 'master' of https://github.com/JensBorrisholt/Delphi-Jso…
JensBorrisholt Dec 20, 2019
dda52da
Added support for annotations
JensBorrisholt Dec 28, 2019
b62a8dc
Added support for Arrany
JensBorrisholt Dec 29, 2019
afd84a1
Update .gitignore
JensBorrisholt Dec 29, 2019
c40a38e
Removed Warnings
JensBorrisholt Jan 13, 2020
799b796
Update uUpdate.pas
JensBorrisholt Jan 13, 2020
0219876
Fixed bug in Github Communication
JensBorrisholt Jan 25, 2020
214628f
TObjectList Generation
JensBorrisholt Mar 3, 2020
1059e79
Update README.md
JensBorrisholt Mar 3, 2020
45b8e98
Create WebAPP.json
JensBorrisholt Mar 4, 2020
5191492
Merge branch 'master' of https://github.com/JensBorrisholt/Delphi-Jso…
JensBorrisholt Mar 4, 2020
1609b9d
Added missing using
JensBorrisholt Apr 9, 2020
35a0cdc
Bugfix in generator
JensBorrisholt Apr 9, 2020
886af24
Bugfix for number parsting
JensBorrisholt May 14, 2020
e7fdb73
Bugfix for numbers inside a string
JensBorrisholt May 14, 2020
21ad021
Mapping fix
JensBorrisholt May 15, 2020
b0d568d
Merge branch 'master' into Feature/MultibleItems
JensBorrisholt May 16, 2020
5e6b841
Multible Items
JensBorrisholt May 16, 2020
6ac907f
Merge branch 'Feature/MultibleItems'
JensBorrisholt May 16, 2020
98a2e87
Removed a Warning
JensBorrisholt May 16, 2020
a14459d
Merge branch 'Feature/MultibleItems'
JensBorrisholt May 16, 2020
1d1e870
Update README.md
JensBorrisholt May 16, 2020
0928018
Rollbaack Array feature
JensBorrisholt May 30, 2020
098a93a
Updated .GitIgnore
JensBorrisholt Jul 7, 2020
2c29599
Merge remote-tracking branch 'origin/master'
JensBorrisholt Jul 7, 2020
024dd3e
Support for Arrays with simple types
JensBorrisholt Jul 7, 2020
af6a7b4
Merge branch 'Feature/NonObjectArray'
JensBorrisholt Jul 7, 2020
374d57e
More demo data
JensBorrisholt Jul 7, 2020
a356038
More demo data
JensBorrisholt Jul 13, 2020
d41767a
Demo data
JensBorrisholt Jul 13, 2020
7875cde
Support for Empty Anonymous Array
JensBorrisholt Jul 13, 2020
a29afdb
Support for Anonymous Arrays
JensBorrisholt Jul 13, 2020
64383ae
WIP
JensBorrisholt Jul 13, 2020
c1b4e41
DEV DONE - Needs test
JensBorrisholt Jul 13, 2020
c22d249
Fixed CapitalizeFirst
JensBorrisholt Jul 14, 2020
3dafc9f
WIP: Classes only generated once!
JensBorrisholt Jul 16, 2020
ef61e93
Code restructure
JensBorrisholt Jul 17, 2020
0e061ae
Bugfix for missing constructor
JensBorrisholt Jul 17, 2020
10da609
Merge Array EOD
JensBorrisholt Jul 19, 2020
44ad3d1
Merge branch 'Feature/MergeArrays'
JensBorrisholt Jul 19, 2020
e8e792c
Demo Generator first check in
JensBorrisholt Jul 26, 2020
59a1e80
Code restructored. Start on E2E test
JensBorrisholt Jul 27, 2020
f4e3fc9
End 2 End Test
JensBorrisholt Jul 27, 2020
5373324
Removed Shell execute from E2E Test
JensBorrisholt Jul 27, 2020
9367245
Merge branch 'Feature/DemoGenerator'
JensBorrisholt Jul 27, 2020
f343899
Bugfix: Object types now generates readonly properties
JensBorrisholt Jul 27, 2020
5089e56
Changed the TDateTime detection part. Now date and time, with optiona…
JensBorrisholt Jul 27, 2020
6d5bc4f
Fixed type
JensBorrisholt Jul 27, 2020
1493b2e
Fixed typo
JensBorrisholt Jul 27, 2020
59467be
Bugfix for Property Annotations
JensBorrisholt Jul 28, 2020
1cb7754
Merge branch 'BUG/Arrays'
JensBorrisholt Jul 28, 2020
ec57b5b
WIP
JensBorrisholt Jul 28, 2020
629f1a6
Bugfix for string generation
JensBorrisholt Jul 28, 2020
fc70e8d
Merge branch 'master' into Festure/UnitTest
JensBorrisholt Jul 28, 2020
bbda342
WIP
JensBorrisholt Jul 28, 2020
2504199
Added unit testing
JensBorrisholt Jul 30, 2020
ee2727a
Merge branch 'Festure/UnitTest'
JensBorrisholt Jul 30, 2020
a66c7e4
Bug Fix for serialization
JensBorrisholt Jul 31, 2020
65164eb
Merge branch 'BUG/PropertyAnnotation'
JensBorrisholt Jul 31, 2020
1bad8ff
Program version
JensBorrisholt Jul 31, 2020
8bc0602
Merge branch 'master' into Feature/uGitHUB
JensBorrisholt Aug 1, 2020
cbd2793
Major cleanup in the Update checker
JensBorrisholt Aug 1, 2020
f4587f1
Merge branch 'Feature/uGitHUB' into Development
JensBorrisholt Aug 1, 2020
6ce80f5
E2E test Cleanup
JensBorrisholt Aug 1, 2020
fe75b4a
Merge branch 'Development' into Feature/uGitHUB
JensBorrisholt Aug 1, 2020
a0f9ad6
Merge branch 'Feature/uGitHUB' into Development
JensBorrisholt Aug 1, 2020
4e8ae81
Fixed memory leak
JensBorrisholt Aug 2, 2020
8f1dfcd
Merge branch 'Development' into Feature/uGitHUB
JensBorrisholt Aug 2, 2020
1bbd436
Merge branch 'Feature/uGitHUB' into Development
JensBorrisholt Aug 2, 2020
817812c
Merge branch 'Development'
JensBorrisholt Aug 2, 2020
d63fdf1
Merge branch 'master' into Development
JensBorrisholt Aug 2, 2020
7d3b07e
Check for missig directory
JensBorrisholt Aug 3, 2020
71b2c9e
Bugfix: Forward declarations
JensBorrisholt Aug 16, 2020
9150d49
Update Pkg.Json.StubField.pas
djonekreusch Oct 5, 2020
9ac38a5
New Feature: PascalCase
JensBorrisholt Nov 10, 2020
1058321
Merge branch 'Feature/Settings' into Development
JensBorrisholt Nov 10, 2020
0b657e2
Merge pull request #1 from djonekreusch/master
JensBorrisholt Nov 10, 2020
aab5511
Merge branch 'master' into Feature/Settings
JensBorrisholt Nov 10, 2020
fc766be
Merge branch 'Development' into Feature/Settings
JensBorrisholt Nov 10, 2020
c6364c0
Merge branch 'Feature/Settings' into Development
JensBorrisholt Nov 10, 2020
2c985a6
Merge branch 'Development'
JensBorrisholt Nov 10, 2020
7884455
JSON.DTO Updated
JensBorrisholt Nov 22, 2020
7ee7a02
WIP
JensBorrisholt Nov 22, 2020
96606c0
Simple Array implementation
JensBorrisholt Nov 22, 2020
a4b3999
Suppress surplus Class inplementation
JensBorrisholt Nov 22, 2020
89de57e
Fixed bug in demo generator
JensBorrisholt Nov 22, 2020
e3825a9
Merge branch 'master' into Development
JensBorrisholt Nov 22, 2020
d03216f
Merge branch 'Development'
JensBorrisholt Nov 22, 2020
8b0ca68
Update README.md
JensBorrisholt Nov 22, 2020
6e3be78
Update README.md
JensBorrisholt Nov 22, 2020
4b39c33
Update README.md
JensBorrisholt Nov 23, 2020
af1e290
Update README.md
JensBorrisholt Nov 23, 2020
f629e58
Merge branch 'Development' into Feature/Settings
JensBorrisholt Nov 24, 2020
923513b
More settings
JensBorrisholt Nov 24, 2020
dd8ee9d
Merge branch 'Feature/Settings' into Development
JensBorrisholt Nov 24, 2020
c5e9b7a
Merge branch 'master' into Development
JensBorrisholt Nov 24, 2020
115c9a8
Merge branch 'Development'
JensBorrisholt Nov 24, 2020
1e02661
Update README.md
JensBorrisholt Nov 24, 2020
deeb3ce
Update README.md
JensBorrisholt Nov 24, 2020
ef288ab
Bug fixes
JensBorrisholt Dec 11, 2020
2442103
Merge branch 'master' into Development
JensBorrisholt Dec 11, 2020
9112235
Merge branch 'Development'
JensBorrisholt Dec 11, 2020
35bf59e
Update README.md
JensBorrisholt Dec 11, 2020
4251306
Update README.md
JensBorrisholt Dec 15, 2020
6685ee4
Merge branch 'master' into Development
JensBorrisholt Dec 19, 2020
e6dd441
WIP
JensBorrisholt Dec 19, 2020
cd0ad89
New main form
JensBorrisholt Dec 22, 2020
584cf96
Merge branch 'Development'
JensBorrisholt Dec 22, 2020
fc2f304
Update README.md
JensBorrisholt Dec 22, 2020
39258ea
Merge remote-tracking branch 'origin/master' into Development
JensBorrisholt Mar 26, 2021
4bb85a2
Fix for multible NoName classes
JensBorrisholt Mar 26, 2021
05cfdca
Merge branch 'Feature/NoNameClasses' into Development
JensBorrisholt Mar 26, 2021
30abad1
Merge branch 'Development'
JensBorrisholt Mar 26, 2021
b8614f8
Update README.md
JensBorrisholt Mar 26, 2021
2d5d08e
Minor bugfix
JensBorrisholt Mar 27, 2021
c5fb455
Merge branch 'master' into Development
JensBorrisholt Mar 27, 2021
e2a61f6
Merge remote-tracking branch 'origin/master'
JensBorrisholt Mar 27, 2021
41236b8
Merge branch 'master' into Development
JensBorrisholt Mar 27, 2021
f6cb5d2
Merge branch 'Development'
JensBorrisholt Mar 27, 2021
0777630
WIP
JensBorrisholt Mar 27, 2021
601fb67
Action List Update calls are checking JSON repeatedly causing high CP…
MarkRSill Mar 27, 2021
51c4031
Merge pull request #2 from JensBorrisholt/Issue-out-of-memory
JensBorrisholt Mar 28, 2021
44fe50a
Bug fixes
JensBorrisholt Jun 4, 2021
6a54d16
Merge branch 'master' into Development
JensBorrisholt Jun 4, 2021
d6ca365
Merge branch 'Development'
JensBorrisholt Jun 4, 2021
1f49a4b
Update README.md
JensBorrisholt Jun 4, 2021
402a358
Update README.md
JensBorrisholt Jun 5, 2021
7769c0f
Update README.md
JensBorrisholt Jun 10, 2021
25655b9
Fix for Issue #20: No name nested arrays
JensBorrisholt Sep 13, 2021
fbe9f51
Merge remote-tracking branch 'origin/master'
JensBorrisholt Sep 13, 2021
ec2a86e
New feature SuppressZero
JensBorrisholt Oct 3, 2021
36298f8
Merge branch 'Feature/NullableDates'
JensBorrisholt Oct 3, 2021
d1cc764
Update README.md
JensBorrisholt Oct 3, 2021
331aaf1
Update README.md
JensBorrisholt Oct 3, 2021
0d71e57
Update README.md
JensBorrisholt Oct 3, 2021
f1cfe0f
Suppress Zero Example
JensBorrisholt Oct 3, 2021
a8508cc
Git ignore
JensBorrisholt Oct 3, 2021
df16561
Revert "Git ignore "
JensBorrisholt Oct 3, 2021
230f917
Merge branch 'Feature/NullableDates'
JensBorrisholt Oct 3, 2021
8e7b1da
Removed unused file
JensBorrisholt Oct 3, 2021
49b3b75
Update README.md
JensBorrisholt Oct 3, 2021
dbfe495
Source code for www.Json2Delphi.com
JensBorrisholt Dec 23, 2021
74c2def
Added button for downloading base class
JensBorrisholt Dec 23, 2021
885b206
Update README.md
JensBorrisholt Dec 23, 2021
bacfc17
Update README.md
JensBorrisholt Dec 23, 2021
f4b2c33
Updated the front page
JensBorrisholt Feb 5, 2022
830dc49
Merge remote-tracking branch 'origin/master'
JensBorrisholt Feb 5, 2022
edbda38
Update README.md
JensBorrisholt Feb 6, 2022
b08bb99
Upgrade to Delphi 12
JensBorrisholt Jan 19, 2024
3108993
Update README.md
JensBorrisholt Jan 19, 2024
3bc068f
Update README.md
JensBorrisholt Jan 19, 2024
4a2e233
Merge pull request #3 from JensBorrisholt/JensBorrisholt-patch-1
JensBorrisholt Jan 19, 2024
894d747
Merge branch 'master' into Development
JensBorrisholt Jan 19, 2024
a1c08cd
ReRemoved memoryleaks in Update check
JensBorrisholt Jan 19, 2024
210bbd6
Removed memleak in actSaveAsExecute
JensBorrisholt Jan 19, 2024
599f864
Added missing Reserved Words
JensBorrisholt Jan 19, 2024
af6edcc
Merge branch 'Development'
JensBorrisholt Jan 19, 2024
af3ff6e
Merge pull request #4 from JensBorrisholt/Development
JensBorrisholt Jan 19, 2024
b92fcea
Update README.md
JensBorrisholt Jan 19, 2024
f2af011
Merge pull request #5 from JensBorrisholt/JensBorrisholt-patch-2
JensBorrisholt Jan 19, 2024
2527d82
Upgrade version number to 3.1
JensBorrisholt Jan 20, 2024
2e119a4
Merge pull request #6 from JensBorrisholt/Development
JensBorrisholt Jan 20, 2024
89a3ced
removed Indy form Update check
JensBorrisholt Jan 20, 2024
e2a6bae
Removed Indy form Update check
JensBorrisholt Jan 20, 2024
3f7a37c
Code CleanUP step 1
JensBorrisholt Jan 27, 2024
06b93a1
Merge branch 'Development' of https://github.com/JensBorrisholt/Delph…
JensBorrisholt Jan 27, 2024
ec2274a
Fixed ReleaseDTO
JensBorrisholt Jan 27, 2024
56235fc
File Rename
JensBorrisholt Jan 27, 2024
7fd2e75
Removed INDY
JensBorrisholt Jan 27, 2024
211773b
Forward classes only generated if there are more than 1 SubClassl
JensBorrisholt Jan 30, 2024
a752e00
Merge branch 'master' of https://github.com/JensBorrisholt/Delphi-Jso…
JensBorrisholt Jan 30, 2024
35ee294
Merge branch 'Development'
JensBorrisholt Jan 30, 2024
ba56aab
Update README.md
JensBorrisholt Jan 30, 2024
8f1c050
Merge pull request #7 from JensBorrisholt/JensBorrisholt-patch-3
JensBorrisholt Jan 30, 2024
9c2da4e
Update README.md
JensBorrisholt Jan 30, 2024
a4be65f
Added a Demo getting JSON from a API
JensBorrisholt Feb 1, 2024
3a6828b
Merge branch 'master' of https://github.com/JensBorrisholt/Delphi-Jso…
JensBorrisholt Feb 1, 2024
e9ccd60
Demo Image
JensBorrisholt Feb 1, 2024
d77ad38
Update README.md
JensBorrisholt Feb 1, 2024
c93374f
Update README.md
JensBorrisholt Feb 1, 2024
a3a0238
Merge pull request #8 from JensBorrisholt/JensBorrisholt-patch-4
JensBorrisholt Feb 1, 2024
544065f
Merge branch 'master' into Development
JensBorrisholt Feb 3, 2024
7cee2fb
Merge branch 'master' into Development
JensBorrisholt Feb 3, 2024
276c2ac
Merge branch 'Development' of https://github.com/JensBorrisholt/Delph…
JensBorrisholt Feb 3, 2024
d4acc8a
Merge branch 'master' into Development
JensBorrisholt Feb 3, 2024
c651a62
Merge branch 'Development' of https://github.com/JensBorrisholt/Delph…
JensBorrisholt Feb 3, 2024
63c7285
Authenticaticed Demo
JensBorrisholt Feb 4, 2024
d1918dd
Update ReadME
JensBorrisholt Feb 4, 2024
3f9a811
Merge branch 'Development'
JensBorrisholt Feb 4, 2024
c9fbcd2
Update ReadMe
JensBorrisholt Feb 4, 2024
ce029bb
Merge branch 'master' into Development
JensBorrisholt Feb 4, 2024
e450ad0
Merge branch 'Development'
JensBorrisholt Feb 4, 2024
81fb305
Minor Code cleanup
JensBorrisholt Feb 4, 2024
8841a4f
Fixed minor Typo
JensBorrisholt Feb 4, 2024
62b7153
Merge branch 'master' into Development
JensBorrisholt Feb 4, 2024
39b8870
WIP
JensBorrisholt Jun 17, 2024
e7039fd
Feature: jtUnknown mapped to a string
Jun 17, 2024
cc7474c
Merge branch 'Developement/NulTypes' into Development
Jun 17, 2024
b22fc8f
Update ReadME
Jun 17, 2024
fd4b261
Merge branch 'Development'
Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 102 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,105 @@

# Delphi history and backups
__history/
*.~*
__recover/
__recovery/
Win32/
Win64/
*.~*

__recovery/uMainForm.pas
__recovery/uMainForm.fmx
__recovery/__recovery.ini



Unit Test/__recovery/

Unit Test/Win32/Debug/

*.skincfg

*.vlb

*.res


###################
# WEB APP #
###################

###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo
# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll
!/packages/*/lib/*/*.dll
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
####################
# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/
###############
# Directories #
###############
bin/
obj/
TestResults/
###################
# Web publish log #
###################
*.Publish.xml
#############
# Resharper #
#############
/_ReSharper.*
*.ReSharper.*
############
# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
######################
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
[Bb]in
[Oo]bj
[Tt]est[Rr]esults
*.suo
*.user
*.[Cc]ache
*[Rr]esharper*
packages
NuGet.exe
_[Ss]cripts
*.exe
*.dll
*.nupkg
*.ncrunchsolution
*.dot[Cc]over
78 changes: 78 additions & 0 deletions Components/Pkg.Json.Components.Update.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
unit Pkg.Json.Components.Update;

interface

uses
System.JSON, System.SysUtils,

Pkg.JSON.ThreadingEx, DTO.GitHUB.ReleaseDTO;

const
ProgramVersion: double = 3.2;
ProgramUrl = 'https://github.com/JensBorrisholt/Delphi-JsonToDelphiClass';
HTTP_OK = 200;

function CheckForUpdate(AOnFinish: TProc<TRelease, string>): ITaskEx;

implementation

uses
System.Net.HttpClient, System.Net.HttpClientComponent;

function CheckForUpdate(AOnFinish: TProc<TRelease, string>): ITaskEx;
const
UpdateUrl = 'https://api.github.com/repos/JensBorrisholt/Delphi-JsonToDelphiClass/releases';
HTTP_OK = 200;
var
ErrorMessage: string;
Releases: TReleases;
Release: TRelease;
Respons: IHTTPResponse;
begin
Result := TTaskEx.Run(
procedure

begin
Releases := TReleases.Create;
with TNetHTTPClient.Create(nil) do
try
try
Respons := Get(UpdateUrl);

if Respons.StatusCode = HTTP_OK then
Releases.AsJson := Respons.ContentAsString
else
begin
Release := nil;
Exit;


end;

if Releases.Items.Count >= 0 then
begin
Release := Releases.Items.First;
if JsonToFloat(Release.TagName) <= ProgramVersion then
Release := nil;
end
else
Release := nil;

ErrorMessage := '';
except
on e: Exception do
ErrorMessage := e.message;
end;
finally
Free;
end;
end
).ContinueWithInMainThread(
procedure(const aTask: ITaskEx)
begin
AOnFinish(Release, ErrorMessage);
FreeAndNil(Releases);
end, TTaskContinuationOptions.OnlyOnCompleted);
end;

end.
139 changes: 139 additions & 0 deletions Components/Pkg.Json.Visualizer.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
unit Pkg.Json.Visualizer;

interface

uses
FMX.TreeView,

Pkg.Json.Mapper, Pkg.Json.StubField;

Type
JsonVisualizer = class
private
class procedure InternalFormatTreeViewFields(AItem: TTreeViewItem);
class procedure FormatFields(aTreeView: TTreeView);
class procedure InternalVisualize(aTreeViewItem: TTreeViewItem; aClass: TStubClass; AItemStyleLookup: string);

public
// Visualizes stub class structure in a treeview
class procedure Visualize(aTreeView: TTreeView; AItemStyleLookup: string; aJsonString: string); overload;
class procedure Visualize(aTreeView: TTreeView; AItemStyleLookup: string; aMapper: TPkgJsonMapper); overload;
end;

implementation

uses
System.Sysutils, Pkg.Json.JsonValueHelper;

{ TJsonVisualizer }

class procedure JsonVisualizer.Visualize(aTreeView: TTreeView; AItemStyleLookup: string; aJsonString: string);
var
JsonMapper: TPkgJsonMapper;
begin
JsonMapper := TPkgJsonMapper.Create;
try
JsonMapper.Parse(aJsonString);
Visualize(aTreeView, AItemStyleLookup, JsonMapper);
finally
JsonMapper.Free;
end;
end;

class procedure JsonVisualizer.FormatFields(aTreeView: TTreeView);
begin
if aTreeView.Count = 1 then
InternalFormatTreeViewFields(aTreeView.Items[0]);
end;

class procedure JsonVisualizer.InternalFormatTreeViewFields(AItem: TTreeViewItem);
var
LItem: TTreeViewItem;
k: Integer;
LSize, LPos: Integer;
begin
LSize := 0;

// Find max len
for k := 0 to AItem.Count - 1 do
begin
LItem := AItem.Items[k];
LPos := Pos(':', LItem.Text);
if (LPos > 0) AND (LPos > LSize) then
LSize := LPos;
end;

for k := 0 to AItem.Count - 1 do
begin
LItem := AItem.Items[k];
LPos := LSize - Pos(':', LItem.Text);
if (LPos > 0) then
LItem.Text := LItem.Text.Replace(':', StringOfChar(' ', LPos) + ':');

InternalFormatTreeViewFields(LItem);
end;

end;

class procedure JsonVisualizer.InternalVisualize(aTreeViewItem: TTreeViewItem; aClass: TStubClass; AItemStyleLookup: string);
var
StubField: TStubField;
TreeViewItem: TTreeViewItem;
begin
for StubField in aClass.Items do
begin
TreeViewItem := TTreeViewItem.Create(aTreeViewItem);
TreeViewItem.StyleLookup := AItemStyleLookup;
TreeViewItem.TagObject := StubField;
TreeViewItem.WordWrap := false;

case StubField.FieldType of
jtObject:
begin
TreeViewItem.Text := StubField.Name + ': {} ' + StubField.TypeAsString;
InternalVisualize(TreeViewItem, (StubField as TStubObjectField).FieldClass, AItemStyleLookup);
end;

jtArray:
begin
TreeViewItem.Text := StubField.Name + ': [] ' + StubField.TypeAsString;
if (StubField as TStubArrayField).ContainedType = jtObject then
InternalVisualize(TreeViewItem, (StubField as TStubArrayField).FieldClass, AItemStyleLookup);
end;

else
TreeViewItem.Text := StubField.Name + ': ' + StubField.TypeAsString;
end;

aTreeViewItem.AddObject(TreeViewItem);
end;
end;

class procedure JsonVisualizer.Visualize(aTreeView: TTreeView; AItemStyleLookup: string; aMapper: TPkgJsonMapper);
var
TreeViewItem: TTreeViewItem;
RootClass: TStubClass;
begin
aTreeView.Clear;
try
RootClass := aMapper.RootClass;
if RootClass = nil then
exit;

aTreeView.BeginUpdate;
TreeViewItem := TTreeViewItem.Create(aTreeView);
TreeViewItem.Text := RootClass.Name;
TreeViewItem.TagObject := RootClass;
TreeViewItem.WordWrap := false;
aTreeView.AddObject(TreeViewItem);
InternalVisualize(TreeViewItem, RootClass, AItemStyleLookup);
FormatFields(aTreeView);
finally
aTreeView.ExpandAll;
aTreeView.EndUpdate;
end;

end;

end.

Loading