Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I use JSONDecode to get an item from a table in an JSONEncoded string?

Code is below v

local a = {
	b = {
		'hi'
		}
	}


local c = game:GetService("HttpService"):JSONEncode(a)

local decoded = game:GetService("HttpService"):JSONDecode(c)

print(decoded.b.hi)

1 answer

✓ Accepted answer

You're doing everything correctly except that your table a, has an index b with the value of a table with the index of 1, with the value of hi. You're indexing your b table with hi (this is the value, not they key) you need to index it by 1 to get the value "hi" back.

print(decoded.b[1])

This discussion is preserved as it was. New answers, comments, and votes are closed.