Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------
- -- INITIALISATION --------------------------------------------
- module(..., package.seeall)
- local JSON = require( "json" )
- --------------------------------------------------------------
- -- FILE FUNCTIONS --------------------------------------------
- -- Encode table to JSON string
- function JSONEncode( data )
- return
- end
- -- Decode JSON string to table
- function JSONDecode( data )
- return JSON.decode(data, 1, nil, {}, {})
- end
- -- Save data to a file
- function saveData(filePath, data)
- file = io.open( filePath, "w" )
- file:write(data)
- io.close( file )
- end
- -- Load data from a file, returning a table
- function loadData(filePath)
- local file = io.open( filePath, "r" )
- if file then
- local data = file:read( "*a" )
- io.close( file )
- return data
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement