29 lines
763 B
Lua
29 lines
763 B
Lua
local jsonList = { 'swade-core-rules.swade-tables.json' }
|
|
local inFolder = '../compendiums/'
|
|
|
|
package.path = package.path .. ";luajson/?.lua"
|
|
local JSON = require'json'
|
|
|
|
for _, jsonFile in pairs(jsonList) do
|
|
local f = io.open(inFolder..jsonFile, "r")
|
|
local jsonIn = f:read("*a")
|
|
f:close()
|
|
|
|
local jsonInData = JSON.decode(jsonIn)
|
|
for key, entry in pairs(jsonInData.entries) do
|
|
if ( entry.results[1]) then
|
|
local newResults = {}
|
|
for key2, result in pairs(entry.results) do
|
|
newResults[tostring(result.range[1].."-"..result.range[2])] = result.text
|
|
end
|
|
entry.results = newResults
|
|
end
|
|
end
|
|
local jsonOut = JSON.encode(jsonInData )
|
|
f= io.open(inFolder..jsonFile.."NEW", "w+")
|
|
f:write(jsonOut)
|
|
f:close()
|
|
|
|
end
|
|
|