require "json" function saveData(key, value) local contents = json.encode(value) --create file local file = io.open( "|D|"..key, "w" ) --save json string in file file:write( contents ) --close file io.close( file ) end function getData(key) local value local file = io.open( "|D|"..key, "r" ) if file then --read contents local contents = file:read( "*a" ) --decode json value = json.decode(contents) --close file io.close( file ) end return value end --try to read information local someData = getData("someData") -- if no information, create it if not someData then someData = {"some text", 42} --save data saveData("someData", someData) print("Creating someData") else print("Read someData", someData[1], someData[2]) end