-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
node.AsJson returns {"Name1":"v1","Name2":"v2"} when it is a root node but return "Name1":"v1","Name2":"v2" (invalid json) if the node is a sub-node.
This is due to the behaviour of FormatCompact (called in the GetAsJson) method. As a temporry workaround, I have modified getAsJson as follows. Kindly advise. TQ.
function TJsonNode.GetAsJson: string;
begin
if FKind in [nkObject, nkArray] then
begin
Result := FormatCompact;
// added:-
// if (FParent <> nil) and (FKind=nkObject) then
if (FKind=nkObject) and (not result.StartsWith('{')) then
result := '{' + result + '}'
end
else
Result := FValue;
end;
Metadata
Metadata
Assignees
Labels
No labels