swade-fr-content-neoflip/tools/convert_rules.lua

27 lines
554 B
Lua
Raw Permalink Normal View History

2023-04-04 07:48:22 +02:00
local jsonList = { 'old-rules.json' }
package.path = package.path .. ";luajson/?.lua"
local JSON = require'json'
for _, jsonFile in pairs(jsonList) do
local f= io.open(jsonFile, "r")
local jsonIn = f:read("*a")
f:close()
local output = {}
local jsonInData = JSON.decode(jsonIn)
for index, entry in pairs(jsonInData.entries) do
output[entry.id] = {
name = entry.name,
text = entry.description
}
end
local jsonOut = JSON.encode( output )
f= io.open("new-rules.json", "w+")
f:write(jsonOut)
f:close()
end