无法在 ROBLOX Lua 中解析 JSON
Can't parse JSON in ROBLOX Lua
我正在制作一个模块脚本,如果调用它的玩家是 JSON 对象中的一个字符串,它会运行另一个模块。
我收到这个错误:
Can't parse JSON
-- Stack Begin
-- Script 'Model.MainModule', Line 8 - function load
-- Stack End
代码:
local module = {}
function module.load(plr)
local HttpService = game:GetService("HttpService")
local decoded = HttpService:JSONDecode('{ players: ["HiroTDM999", "mrhotmadm"] }')
for i, v in pairs(decoded.players) do
if v == plr.Name then
require(6380716368).load() -- runs another module (no json in it)
end
end
end
return module
JSON无效,需要将玩家用双引号括起来
local module = {}
function module.load(plr)
local HttpService = game:GetService("HttpService")
local decoded = HttpService:JSONDecode('{ "players": ["HiroTDM999", "mrhotmadm"] }')
for i, v in pairs(decoded.players) do
if v == plr.Name then
require(6380716368).load() -- runs another module (no json in it)
end
end
end
return module
我正在制作一个模块脚本,如果调用它的玩家是 JSON 对象中的一个字符串,它会运行另一个模块。
我收到这个错误:
Can't parse JSON
-- Stack Begin
-- Script 'Model.MainModule', Line 8 - function load
-- Stack End
代码:
local module = {}
function module.load(plr)
local HttpService = game:GetService("HttpService")
local decoded = HttpService:JSONDecode('{ players: ["HiroTDM999", "mrhotmadm"] }')
for i, v in pairs(decoded.players) do
if v == plr.Name then
require(6380716368).load() -- runs another module (no json in it)
end
end
end
return module
JSON无效,需要将玩家用双引号括起来
local module = {}
function module.load(plr)
local HttpService = game:GetService("HttpService")
local decoded = HttpService:JSONDecode('{ "players": ["HiroTDM999", "mrhotmadm"] }')
for i, v in pairs(decoded.players) do
if v == plr.Name then
require(6380716368).load() -- runs another module (no json in it)
end
end
end
return module