I'm trying to create JSON that looks like this:
{ "guestlist": ["alice","bob","charlie"] }
Typical examples I see for populating a JSON array look like this:
var
jsobj: TJsonObject;
jso : TJsonObject;
jsa : TJsonArray;
jsp : TJsonPair;
begin
jsObj := TJsonObject.Create();
jsa := TJsonArray.Create();
jsp := TJSONPair.Create('guestlist', jsa);
jsObj.AddPair(jsp);
jso := TJsonObject.Create();
jso.AddPair(TJSONPair.Create('person', 'alice'));
jsa.AddElement(jso);
jso := TJsonObject.Create();
jso.AddPair(TJSONPair.Create('person', 'bob'));
jsa.AddElement(jso);
jso := TJsonObject.Create();
jso.AddPair(TJSONPair.Create('person', 'charlie'));
jsa.AddElement(jso);
end;
But that would result in something like this:
{ "guestlist": [{"person":"alice"},{"person":"bob"},{"person":"charlie"}] }
How can I add a single value to the array instead of a pair? I see nothing in the documentation for TJsonObject on how to do this,