There are parsing errors in the JSONDecode function when the function is given empty arrays. The function gives unexpected behavior when parsing these otherwise-valid JSON strings:
JSON Strings which assert the error: attempt to index a string value when sent to HttpService::JSONDecode
{"foo":[]}
{"foo":[],"bar":1}
{"foo":{"bar":[]}}
JSON Strings which will crash ROBLOX altogether when sent to HttpService::JSONDecode
{"foo":[[]]}
JSON Strings which do NOT assert an error, and successfully return the expected value
{"foo":[null]}
{"foo":[[null]]}
{"bar":1,"foo":[]}
{"foo":["bar"]}
{"foo":[1]}
Note that this is confirmed to be an internal ROBLOX bug and not an “it’s invalid JSON” bug. This is not the “can’t Parse JSON” error, but rather a different internal bug. According to json.org it is perfectly legal to have empty arrays, yet the function generates an error and even has the crash bug.
There are definitely workarounds in existing code, like tossing in a “null” to your array or adding a dummy key before the array. However, you cannot be assured that the dummy key will be before or after the empty array, so the best workaround I would recommend is adding null as dummy value as the first value.
Please fix these bugs. I had to find them The Hard WayΓäó, and the aftermath wasn’t fun.