Decoding launchdata from deeplinked URL returns half string

Decoding (with HttpService) launchdata that you get from deeplinked URLs will return half of the string (or the beginning of the string) and/or returns “Cannot be parsed JSON”;

Demo code for an example;

local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function (plr)
	local launchData = plr:GetJoinData().LaunchData
	
	print(launchData)
	print(HttpService:JSONDecode(launchData))
end)

Examples of it happening:
Cannot parse to JSON" error or returns just {"id :

https://www.roblox.com/games/start?launchData=[{"id": "ssssa"},{"hub": "ssss"}]&placeId=17408110728
https://www.roblox.com/games/start?launchData=[{"hi": "smth"}, {"something": 100}]&placeId=17408110728

Screenshots of some of the debugging messages:
(below is a string, and cannot be parsed into JSON)


image

Expected behavior

For HttpService:JSONDecode() to be able to decode it into a Lua table;

2 Likes

Thanks for the report. Just to clarify: are you seeing this from anywhere other than Windows clients? This sounds a lot like an issue we’ve seen, and don’t have a fix for, where Windows automatically URL decodes the link before giving it to us on the command line, resulting in quotation marks being stripped out and spaces messing up our parsing(in your example, that’d explain the missing “ after id and the rest of it being missing since there’s that space after the colon). Have you tried using a Base64 encoding rather than normal URL encoding?

Right now, I’ve only had it happen on Windows and sometimes base64 works and sometimes it doesn’t…roblox is really picky on what it will accept

Thanks, can you provide a Base64 version that doesn’t work? If we can reproduce it locally, that’ll help a lot in terms of fixing the issue. URL encoded JSON on Windows is, unfortunately just something we don’t have much of a way to fix right now.

Here, I’ll just send you everything I tried and then put the results here:

  • https://www.roblox.com/games/start?launchData=[{"id": "ssssa"},{"hub": "ssss"}]&placeId=17408110728
    https://i.imgur.com/wZkIDar.png

  • With Base64 Encoding:
    https://www.roblox.com/games/start?launchData=W3siaWQiOiAic3Nzc2EifSx7Imh1YiI6ICJzc3NzIn1d&placeId=17408110728
    https://i.imgur.com/SJXW47J.png

  • https://www.roblox.com/games/start?launchData=%5B%7B%22id%22%3A%20%22ssssa%22%7D%2C%7B%22hub%22%3A%20%22ssss%22%7D%5D&placeId=17408110728
    https://i.imgur.com/79wcKY8.png

Even with encoding the URL, it will still print the exact same thing. Let me know if you need anything else.

Here’s the place file:
encoding_issue.rbxl (95.5 KB)

1 Like

This is great! Thanks, we’ll take a look.

Ahhh, ok. Looking at the Base64 result, it looks like your scripts are getting the full string you passed in, but it’s just still encoded so isn’t valid JSON. We don’t automatically decode those, so that’s something you’d need to do in your script. Poking around, there are some community resources that can help to do that(https://create.roblox.com/store/asset/11436058206/Base64?externalSource=www or for a simple function to copy/paste into your code: Base64 Encoding and Decoding in Lua) and I expect that once you decode it, it should work well.

1 Like

Yep, it works well! I guess that’s the problem, I should open up a feature request for a function for encoding/decoding in Base64s. Thank you for your help!

Are there any plans to do this with Roblox encoding/decoding these links?

I don’t think we have plans along those lines; for right now Base64 encoding is more of a workaround. But we are looking at ways to try to generally get around this issue of Windows breaking the URL-encoded data. And we’ll definitely post an update when we figure out something better.

2 Likes