Hi there, i was making a system using github and it requires JSON.
Everytime the game runs, It hits me hard with the error “Can’t Parse JSON”
I tried fixing everything but it didnt work.
Here is the code:
local HTTP = game:GetService("HttpService")
local RepositoryName = "PacketDataStorage"
local GitHubAccountUsername = "jojogamezHub"
local StorageURL = "https://github.com/jojogamezHub/PacketDataStorage/tree/main/PacketData/"
local function GetPacketData(FilmName)
warn("Getting Packet Data:",FilmName)
local PacketData = {}
local Config
local PreConfig
repeat
local Success,ErrorMsg = pcall(function()
local URL = string.format(StorageURL .. "%s/%s",FilmName,"config.json")
local EncodedData = HTTP:GetAsync(URL)
print("Got Config")
Config = HTTP:JSONDecode(URL)
end)
if not Success then warn(ErrorMsg) task.wait(1) end
until Success
local Packets = Config["packets"]
local TotalFrameIteration = 0
print("Getting",Packets,"Packets")
local PrevProgressPercent = 0
for PacketIndex = 1,Packets do
local ProgressPercent = math.floor((PacketIndex/Packets)*100)
if ProgressPercent > PrevProgressPercent then print("Progress:",ProgressPercent .."%") PrevProgressPercent = ProgressPercent end
local URL = string.format(StorageURL .. "%s/%s",FilmName,PacketIndex .. ".json")
local DecodedData
repeat
local Success,ErrorMsg = pcall(function()
local EncodedData = HTTP:GetAsync(URL)
DecodedData = HTTP:JSONDecode(EncodedData)
end)
if not Success then warn(ErrorMsg) task.wait(1) end
until Success
PacketData[PacketIndex] = DecodedData
--[[for _,FrameData in ipairs(PacketData) do
TotalFrameIteration += 1
for XNum, XData in ipairs(FrameData) do
for YNum, YData in ipairs(XData)do
FrameData[XNum][YNum] = Color3.fromRGB(YData[1],YData[2],YData[3])
end
end
PixelData[TotalFrameIteration] = FrameData
end]]
end
return Config,PacketData
end
local FilmData = {
{
["FilmName"] = "TheBeatdown",
["SoundId"] = 0,
["SoundVolume"] = 10,
["PlaybackSpeed"] = 1,
}
}
local PacketData = {}
local NumFilms = #FilmData
for i,Data in ipairs(FilmData) do -- format data
local FilmName = Data.FilmName
PacketData[FilmName] = {}
Data["Config"],PacketData[FilmName] = GetPacketData(FilmName)
FilmData[FilmName] = Data
FilmData[i] = nil
if i < NumFilms then
task.wait(5) -- cooldown
end
end
local Data = {
["FilmData"] = FilmData,
["PacketData"] = PacketData,
}
return Data
I need help as i am trying to get rid of the error and let the script run.