Hi all,
I have a tricky puzzle on my hands (I like to think of Programming as puzzle solving)
I need to identify a table from a series of variables that could be anything - e.g:
[lua]json = require(“json”)
readTable = {}
variableTable = {}
path = system.pathForFile(“file.JSON”)
openedPath = io.open(path, “r”)
readPath = openedPath:read("*a")
variableTable = decode.json(readPath)
for k,v in pairs(variableTable) do
print (k,v)
readTable[k] = v
end[/lua]
The problem here is that the JSON file contains sections within sections and, when the JSON is decoded they appear as tables (Which is fine) I just need an automated way of deciding what a table is so that i can pass that onto a for loop so it is able to load everything into an array.
So, my question is, how do I tell the if statement (Which will decide what is and what isn’t a table) what to evaluate upon - e.g:
[lua]if readTable[k] == whatever A Table Identifier Is then
…
end[/lua]
(Before you ask, I am unable to upload the JSON file because it contains sensitive information. Sorry!) [import]uid: 65237 topic_id: 30800 reply_id: 330800[/import]