Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.66 KB

saveTable.markdown

File metadata and controls

48 lines (33 loc) · 1.66 KB

PLUGIN_NAME.saveTable()

 
Type function
Library PLUGIN_NAME.*
Return value Boolean
Keywords json
See also PLUGIN_NAME.loadTable()

Overview

This function saves a Lua table to a JSON file

Syntax

PLUGIN_NAME.saveTable( t, filename )
PLUGIN_NAME.saveTable( t, filename, baseDirectory )
t (required)

Table. The Lua table you want to persist to a file.

filename (required)

String. The name of the file that will contain the JSON data.

baseDirectory (optional)

Constant. Constant corresponding to the base directory where the file is located. Default value is system.DocumentsDirectory if the parameter is not provided.

Examples

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" )