Skip to content
Open
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions jsontools.pas
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ TJsonNode = class
procedure ParseObject(Node: TJsonNode; var C: PChar);
procedure ParseArray(Node: TJsonNode; var C: PChar);
procedure Error(const Msg: string = '');
function Format(const Indent: string): string;
function FormatCompact: string;
function Format(const Indent: string; IncludeKey: Boolean = False): string;
function FormatCompact(IncludeKey: Boolean = False): string;
function Add(Kind: TJsonNodeKind; const Name, Value: string): TJsonNode; overload;
function GetRoot: TJsonNode;
procedure SetKind(Value: TJsonNodeKind);
Expand Down Expand Up @@ -1147,7 +1147,7 @@ function TJsonNode.Force(const Path: string): TJsonNode;
Result := N;
end;

function TJsonNode.Format(const Indent: string): string;
function TJsonNode.Format(const Indent: string; IncludeKey: Boolean = False): string;

function EnumNodes: string;
var
Expand All @@ -1161,7 +1161,7 @@ function TJsonNode.Format(const Indent: string): string;
S := Indent + #9;
for I := 0 to J do
begin
Result := Result + TJsonNode(FList[I]).Format(S);
Result := Result + TJsonNode(FList[I]).Format(S, True);
if I < J then
Result := Result + ','#10
else
Expand All @@ -1173,7 +1173,7 @@ function TJsonNode.Format(const Indent: string): string;
Prefix: string;
begin
Result := '';
if (FParent <> nil) and (FParent.FKind = nkObject) then
if IncludeKey and (FParent.FKind = nkObject) then
Prefix := JsonStringEncode(FName) + ': '
else
Prefix := '';
Expand All @@ -1185,7 +1185,7 @@ function TJsonNode.Format(const Indent: string): string;
end;
end;

function TJsonNode.FormatCompact: string;
function TJsonNode.FormatCompact(IncludeKey: Boolean = False): string;

function EnumNodes: string;
var
Expand All @@ -1197,7 +1197,7 @@ function TJsonNode.FormatCompact: string;
J := FList.Count - 1;
for I := 0 to J do
begin
Result := Result + TJsonNode(FList[I]).FormatCompact;
Result := Result + TJsonNode(FList[I]).FormatCompact(True);
if I < J then
Result := Result + ',';
end;
Expand All @@ -1207,7 +1207,7 @@ function TJsonNode.FormatCompact: string;
Prefix: string;
begin
Result := '';
if (FParent <> nil) and (FParent.FKind = nkObject) then
if IncludeKey and (FParent.FKind = nkObject) then
Prefix := JsonStringEncode(FName) + ':'
else
Prefix := '';
Expand Down