Type | function |
Library | PLUGIN_NAME.* |
Return value | Boolean |
Keywords | json |
See also | PLUGIN_NAME.loadTable() |
This function saves a Lua table to a JSON file
PLUGIN_NAME.saveTable( t, filename )
PLUGIN_NAME.saveTable( t, filename, baseDirectory )
Table. The Lua table you want to persist to a file.
String. The name of the file that will contain the JSON data.
Constant. Constant corresponding to the base directory where the file is located. Default value is system.DocumentsDirectory if the parameter is not provided.
local PLUGIN_NAME = require 'plugin.PLUGIN_NAME'
local colors =
{
{ name = "red", value = { 1, 0, 0, 1 }, },
{ name = "green", value = { 0, 1, 0, 1 }, },
{ name = "blue", value = { 0, 0, 1, 1 }, },
{ name = "cyan", value = { 0, 1, 1, 1 }, },
{ name = "magenta", value = { 1, 0, 1, 1 }, },
{ name = "yellow", value = { 1, 1, 0, 1 }, },
}
PLUGIN_NAME.saveTable( colors, "colors.json" )