Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TMyController.Index;
- var
- StringWriter: TStringWriter;
- Writer: TJSONTextWriter;
- oUser: String;
- Arr: TArray<String>;
- begin
- StringWriter := TStringWriter.Create();
- Writer := TJsonTextWriter.Create(StringWriter);
- try
- Writer.Formatting := TJsonFormatting.Indented;
- Writer.WriteStartObject;
- Writer.WritePropertyName('Users');
- Writer.WriteStartArray;
- Arr := ['Daniele','Peter','Scott'];
- for oUser in Arr do
- begin
- Writer.WriteStartObject;
- Writer.WritePropertyName('UserName');
- Writer.WriteValue(oUser);
- Writer.WriteEndObject;
- end;
- Writer.WriteEndArray;
- Writer.WriteEndObject;
- Render(StringWriter, False);
- finally
- Writer.Free;
- StringWriter.Free;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement