I have to place a JSON string to a HTTP request's body. One of the string value must be a JSON array. This is how I tried:
uses
DBXJSON;
const
cContent = 'hello world';
var
LJSONObject: TJSONObject;
x: TBytes;
i: integer;
Temp: string;
begin
LJSONObject:= TJSONObject.Create;
LJSONObject.AddPair('id1', 'value1');
LJSONObject.AddPair('id2', 'value2');
LJSONObject.AddPair('id2', 'value3');
x:= TEncoding.ANSI.GetBytes(cContent);
Temp:= '';
for i := 0 to Length(x) - 1 do
Temp:= Temp + IntToStr(x[i]) + ',';
Delete(Temp, Length(Temp), 1);
LJSONObject.AddPair('id4', '[' + Temp + ']');
ShowMessage(LJSONObject.ToString);
end;
This one is not working, because the value will be encapsulated in double quotes. What is the proper way to pass an array value to the JSONObject?