This EPGP World of Warcraft addon displays the epgp.lua database file.
I wrote a plugin to convert Lua data to a JSON object for display on a guild website. It worked in older versions of the addon, but now I have problems trying to get it to convert the file correctly. Here are two snippets that show the conversion problem - see this demo .
The first works great when forming a nested array:
["roster_info"] = {
{
"Agantica", -- [1]
"ROGUE", -- [2]
"09/03-2013", -- [3]
}, -- [1]
{
"Intikamim", -- [1]
"PALADIN", -- [2]
"17/02-2013", -- [3]
}, -- [2]
},
becomes
"roster_info" : [
[
"Agantica",
"ROGUE",
"09/03-2013"
],
[
"Intikamim",
"PALADIN",
"17/02-2013"
]
]
But overriding strings sees this next fragment as a nested array when it should be an object inside the array:
["bonus_loot_log"] = {
{
["player"] = "Magebox",
["timestamp"] = "2013-03-07 13:44:00",
["coinsLeft"] = "-1",
["reward"] = "|cffa335ee|Hitem:86815:0:0:0:0:0:0:632235520:90:0:445|h[Attenuating Bracers]|h|r",
}, -- [1]
{
["player"] = "Lîutasila",
["coinsLeft"] = "-1",
["timestamp"] = "2013-03-07 13:47:00",
}, -- [2]
},
becomes
"bonus_loot_log" : [
[
"player" : "Magebox",
"timestamp" : "2013-03-07 13:44:00",
"coinsLeft" : "-1",
"reward" : "|cffa335ee|Hitem:86815:0:0:0:0:0:0:632235520:90:0:445|h[Attenuating Bracers]|h|r"
],
[
"player": "Lîutasila",
"coinsLeft": "-1",
"timestamp": "2013-03-07 13:47:00"
]
]
Here is a string conversion script that only works with the first fragment.
lua_string
.replace(/\[(.*)\]\s\=\s/g,'$1:')
.replace(/[\t\r\n]/g,'')
.replace(/\}\,\s--\s\[\d+\]\}/g,']]')
.replace(/\,\s--\s\[\d+\]/g,',')
.replace(/,(\}|\])/g,'$1')
.replace(/\}\,\{/g,'],[')
.replace(/\{\{/g,'[[')
.replace(/EPGP_DB\s\=/,'');
, , Lua ( ).