"Can't parse JSON" error with valid json?

  1. What do you want to achieve?
    I am trying to send a table of information from one script to another using a string variable (more specifically the Text attribute of a TextLabel, since I need the table for that).
    To achieve this I turn the table into a JSON string and then I turn it back into a table.

  2. What is the issue?
    The issue is that, when decoding, it returns me the parse error, despite the JSON being valid:


--HOW I CHANGE THE TEXT OF THE LABEL
item_description.Text = http_service:JSONEncode(decoration.Description)

-- FUNCTION RESPONSIBLE FOR RECEIVING INFORMATION
function get_text_info(text : string)
	print(text)
	local info = http_service:JSONDecode(text)
	local text = ""
	
	for _,nib in info do
		text = text .. nib.Text
	end
	
	return text, info
end

Oh, and also this is the description:

["Description"] = {
			{
				["Text"] = "A stack of pumpkins", 
				["Color"] = "#FF995A"
			},
			{
				["Text"] = ". Legend says, that they belong to ",
				["Color"] = "#FFFFFF"
			},
			{
				["Text"] = "The Headless Horseman",
				["Color"] = "#7D2828",
				["Shake"] = true
			},
			{
				["Text"] = ".",
				["Color"] = "#FFFFFF"
			}
		}

From your screenshot:
image
It seems that there is a time when no value is passed for the text parameter, causing the error.

When there is no value provided, there is nothing for the JSON decoder to check, so it just errors.

2 Likes

Oh! Thanks for noticing! I know exactly what’s causing it now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.