Limitation to :JSONDecode

so when i try to do :JSONDecode on a json string (that i am aware is huge), it errors Script timeout: exhausted allowed execution time?

function:

local function requestPixels(parameters: {[string]: any}): pixelsData
	local url = BASE_URL

	for parameter, v in parameters or {} do
		url ..= `?{parameter}={v}`
	end

	return HttpService:JSONDecode( -- error here
		HttpService:GetAsync(url) or '{}' -- not here
	)
end
2 Likes

Maybe this would help?

3 Likes

i pasted that settings thing to the console and ran the game, it still errors the same thing

2 Likes

You might want to use Parallel Luau then, though I’m can’t guarantee it will work.

1 Like

i do use parallel luau in the background (only for rendering and also in the backend), but how do i parallel luau when the error is coming from :JSONDecode? (which is built-in)

1 Like

The above error occurs when you use a loop without wait. Just add a task.wait() or wait() in the loops and you’ll be good to go!

1 Like

its not the loop, its coming from the :JSONDecode, not anywhere else

1 Like

What are the params your sending? Are they being unpacked via a table or something into the function? (Edit: Saw your using a table, just tell me what params your using)

1 Like

i left the parameters nil because i dont need them anymore

1 Like

It’s still erroring despite not entering the parameters? Print the url out after and before the for loop. Tell me what you get.

local function requestPixels(parameters: {[string]: any}): pixelsData
	local url = BASE_URL
    print(url, "Before")
	for parameter, v in parameters or {} do
		url ..= `?{parameter}={v}`
	end
    print(url, "After")
	return HttpService:JSONDecode( -- error here
		HttpService:GetAsync(url) or '{}' -- not here
	)
end
1 Like

Maybe your spamming the requestpixels function? try lowering the amount.

1 Like

they print out the same url and i don’t think a loop concenating a string would produce that error

no, it will be only called once


sorry for the late response :sweat_smile:
(keep in mind the backend server takes quite some time to return a response (its short enough to not produce a timedout) so it would take time for me to test your solutions)

1 Like

i managed to store the data in a json file; the size says its 2,15,019 KB? what does that mean
image
the shortest and smallest one is 3870 KB

i turned it to a grayscale and now its 2,43,542 KB, i don’t know what that means, but it WORKS with grayscale

1 Like