Hey everyone,
I’m running into an issue that I just can’t figure out. I have a JSON table set up as follows;
[ { "Zipcode": 705, "City": "AIBONITO", "State": "PR" }, { "Zipcode": 36860, "City": "HURTSBORO", "State": "AL" }, { "Zipcode": 91406, "City": "VAN NUYS", "State": "CA" },]
the code to access it is;
local fd = io.open(system.pathForFile("ZIPDATABASE.json")) local data = fd:read('\*a') fd:close() data = json.decode(data) local dbtbl = {} local record for i=1, #data do record = data[i] dbtbl[record["Zipcode"]] = { city = record.City, state = record.State } end
My problem is I keep getting “Table index is nil” as an error. I’m using this method for another database and it works fine. Not really sure whats happening. This is a very large JSON database as it has zip codes for every state in the USA. Would that be contributing to it?
Thanks!
-B