When using HttpService:JSONEncode
on a table with empty spaces between indexes, the values for those indexes are not included in the result. It also only includes values for integer indexes in tables that have both integers and strings as keys. Nevermind, this one is mentioned in the documentation.
Since I don’t know how to explain it very well, here is an example:
local httpService = game:GetService("HttpService")
local t = {
[1] = "hi",
-- no value for 2
[3] = "bye"
}
print(httpService:JSONEncode(t))
Output: ["hi"]
It would be expected for the output to include the values for both 1 and 3, not just 1. It seems to stop if it doesn’t find another number after 1, but it would make more sense for it to include all keys.
If this bus can’t be fixed due to backward-compatibility reasons, possibly 2 more functions of HttpService
could be added (for :JSONEncode
and :JSONDecode
) with fixed versions of these functions. It’s very hard to work with encoding tables when some keys in tables are ignored by the :JSONEncode
function.
I know that this bug report is hard to understand, but I don’t exactly know the right terminology for these things. Hopefully the examples are enough for you to understand what I am trying to say.