Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

JSON Not Converting when it did before, no errors?

Asked by 9 years ago

I have a Trello API script and it used to work. Now I keep getting errors saying:

18:56:03.797 - Can't convert to JSON 18:56:03.799 - Script 'Players.Player.PlayerGui.TeamChange.CallAnAdmin.MainScript', Line 33 18:56:03.800 - Stack End

And I never changed the script before this. Now nothing works, help please?

The script:

--Search
--Script
--Code
--Stuff
--Here (Would have taken up 5 lines)
local Gui = script.Parent
local Abuser = script.Parent.Abuser
local Desc = script.Parent.Desc
local Call = script.Parent.Call
local Sent = script.Parent.Sent
local Enter = 
[[
    ;
]]

local MarketService = game:GetService("MarketplaceService")
local GI = MarketService:GetProductInfo(game.PlaceId)
local Player = script.Parent.Parent.Parent.Parent

local ListID = "55307ad62211032b2a47bb6c"
local Add = "?key=aded73d328dce4a0698a6744856b3326&token="
local Token = "--[[PRIVATE--]]"
local HS = game:GetService("HttpService")
local Thingy = Add..Token

Call.MouseButton1Down:connect(function()
    local Url = "https://api.trello.com/1/cards/"..Thingy
    local data = {
        name = "Game: "..GI.Name.." || From: "..Player.Name,
        desc = "***Caller:*** "..Player.Name..Enter.."***Accused Abuser:*** "..Abuser.Text..Enter.."***Description:*** "..Desc.Text..Enter.."***Game Link:*** ".."http://www.roblox.com/games/"..game.PlaceId.."/GameLink",
        idList = ListID,
        pos = "bottom",
    }
    local Data = HS:JSONEncode(data)
    local Post = HS:PostAsync(Url,Data)
    local Read = HS:JSONDecode(Post)
    Desc.Text = "Brief Description"
    Abuser.Text = "Abuser's Name"
    Sent.Visible = true
    Call.Visible = false
    wait(5)
    Gui.Visible = false
    Sent.Visible = false
    Call.Visible = true
end)
0
I would recommand using UrlEncode instead of using JSON. Example game:GetService("HttpService"):UrlEncode(bleh) MessorAdmin 598 — 9y
0
URL encoding has absolutely nothing to do with JSON encoding. URL encode takes a string and produces another string, using the standard URI encoding scheme for non latin characters BlueTaslem 18071 — 9y
0
The thing is, that it worked before. It randomly stopped. TypicalModerator 110 — 9y

1 answer

Log in to vote
0
Answered by
debugd 5
9 years ago

You're probably pulling in some strange unicode characters from one or more sources. Perhaps a player's name has some abusive characters in it? Non-printable characters? I got it to break with the Registered trademark symbol (R), on Windows: ALT+0174 (®)

Sanitize the data first. Then JSONEncode.

Best, debugd

0
How would you "Sanitize the data first."? TypicalModerator 110 — 9y
Ad

Answer this question