So würde man es ja normalerweise machen:
Delphi-Quellcode:
function TmyClass.GetInfoAsJSON:
string;
var
jWriter: TJsonTextWriter;
textWriter: TTextWriter;
begin
textWriter := TStringWriter.Create;
try
jWriter:=TJsonTextWriter.Create(textWriter);
try
jWriter.WriteStartObject;
jWriter.WritePropertyName('
values');
jWriter.WriteValue('
wuppdi');
jWriter.WriteEndObject;
Result:=jWriter.Writer.ToString;
finally
jWriter.Free;
end;
finally
textWriter.Free;
end;
end;
oder alternativ auch so
Delphi-Quellcode:
function TmyClass.GetInfoAsJSON:
string;
var
jWriter: TJsonTextWriter;
textWriter: TTextWriter;
begin
jWriter :=
nil;
textWriter := TStringWriter.Create;
try
jWriter:=TJsonTextWriter.Create(textWriter);
jWriter.WriteStartObject;
jWriter.WritePropertyName('
values');
jWriter.WriteValue('
wuppdi');
jWriter.WriteEndObject;
Result:=jWriter.Writer.ToString;
finally
jWriter.Free;
textWriter.Free;
end;
end;