json.serialization
json.serialization(table)
Description
This function is utilized convert a Lua table to a JSON string.
Parameters
- table – a Lua table
Return
Returns a JSON string containing the information from the input table.
Examples
-- Convert the dataTable to json and write it to a file on the hard drive
function SaveData()
dataTable = { UIData = {ComboIndex = 1, RadioIndex = 2, Path = "C:\\MyFolder\\"},
Numbers = {X = 1, Y = 2.123, Z = 3.123} }
local f = assert(io.open("C:\\myjsondata.json", "w"))
f:write(json.serialize(dataTable))
f:close()
end