metastruct-experiments/jsonparse_test.lua

39 lines
1 KiB
Lua
Raw Normal View History

2022-06-22 11:04:44 +00:00
local url = "https://raw.githubusercontent.com/sr229/metastruct-experiments/master/starfall_metadata/allowed_google_voices.json"
local data
local function hasValue(table, val)
for i = 1, #table do
if table[i] == val then
return true
end
end
return false
end
2022-06-22 11:04:44 +00:00
http.Fetch(url, function(body, length, headers, code)
if length == 0 then
print("Invalid length! Length should be non-zero.")
return
end
data = util.JSONToTable(body)
print("DEBUG: " .. tostring(data))
PrintTable(data)
2022-06-22 11:21:24 +00:00
say(tostring(data))
-- now to check if we can langselect
local testSetLang = "en"
local langTable = data.voices
PrintTable(langTable)
if hasValue(langTable, testSetLang) then
print("Lang " .. testSetLang .. " is valid!")
say("DEBUG: Langselect Test succeeded now stop being an idiot and actually do your starfall code you little shit.")
else
print("Lang " .. testSetLang .. " is not valid!")
say("DEBUG: Langselect Test did not succeed.")
end
2022-06-22 11:04:44 +00:00
end)