mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
json5 work
This commit is contained in:
parent
cd63b5c9c0
commit
fdd1d145cf
22 changed files with 1977 additions and 90 deletions
|
|
@ -1,4 +1,5 @@
|
|||
local HttpService = game:GetService("HttpService")
|
||||
local JSON5Decoder = require(script.Parent.Parent.json5.JSON5Decoder)
|
||||
|
||||
local stringTemplate = [[
|
||||
Http.Response {
|
||||
|
|
@ -28,7 +29,13 @@ function Response:isSuccess()
|
|||
end
|
||||
|
||||
function Response:json()
|
||||
return HttpService:JSONDecode(self.body)
|
||||
-- Try fast native decode first, fallback to JSON5 for NaN/Infinity
|
||||
local success, result = pcall(HttpService.JSONDecode, HttpService, self.body)
|
||||
if success then
|
||||
return result
|
||||
end
|
||||
print("[HTTP Response:json()] Native decode failed, using JSON5 for size:", #self.body)
|
||||
return JSON5Decoder.Decode(self.body)
|
||||
end
|
||||
|
||||
return Response
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue