HttpService:JSONEncode() successfully encodes most inf or nan values to JSON, but fails to decode them back into lua tables through HttpService:JSONDecode()
Attempting to decode the JSON string will result in a “Can’t parse JSON” error.
Example:
local A = {
0/0,
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
}
print(A)
local HttpService = game:GetService("HttpService")
local B = HttpService:JSONEncode(A)
print(B)
print(HttpService:JSONDecode(B))
Outputs:
table: XXXXXX
[-nan(ind),inf]
Can’t parse JSON
Line 9
Should either error on encoding or successfully manage to decode.