Square Bracket for HTTP service

Hello! I’m trying to get a square bracket for

{"attachments":{"field":{"short":false,"title":"Priority","value":"High"},"title":"Test Documentation","text":"Hello, Dino is cool!"}}

So instead of “attachment”:{“field”… it does “attachment”:[{“field”… when using JSON encoded

Is there any way I can make the lua script encode it as a square bracket? Here is my format before encoded

	local attach = {
		['attachments'] = {
			["title"] = "Test Documentation";
			['text'] = "Test";
			['field'] = (
				{
					["title"] = "Priority";
                    ["value"] = "High";
                    ["short"] = false;
					
				}
			)
			
		};
	}

Thanks for any help :smiley:

Square brackets mean an array.

So lets say you want to generate this:

[{ "name": "foo", "value": "bar" }]

Then you can do:

local t = {}
t[1] = { name = "foo", value = "bar" }
print(game:GetService("HttpService"):JSONEncode(t))
--> [{ "name": "foo", "value": "bar" }]
6 Likes

Thanks so much, Seranok! I really appreciate the help on this one!