I'm taking JSON data from IRE GMCP messages and am trying to get the named index from the table. I keep getting the value and not the key AND value. I tried to test it in immediate execution but MUSHclient yelled at me for trying to
I want to have whatever the index names are in the JSON data be what the index is named in the Lua table.
For example, if I get this from the Achaea:
What I'll end up with is:
I've tried this and a few variations of it so far just to see if I can get the name of the index to print:
require "ipairs"I want to have whatever the index names are in the JSON data be what the index is named in the Lua table.
For example, if I get this from the Achaea:
Char.Name { "name": "myname", "fullname": "myfullname" }What I'll end up with is:
stats = {
name = "myname",
fullname = "myfullname"
}I've tried this and a few variations of it so far just to see if I can get the name of the index to print:
string = [[{"name": "myname", "fullname": "myfullname"}]] -- many values for fullname have single quotes in them.
test = json.decode('[' .. string .. ']')[1]
for k,v in pairs (test) do
print (test[k])
end