textutils.serializeJSON
From ComputerCraft Wiki
Revision as of 20:41, 16 February 2015 by MKlegoman357 (Talk | contribs) (Created page with "{{lowercase}} {{Function |name=textutils.serializeJSON |args={{type|table}}/{{type|string}}/{{type|number}}/{{type|boolean}} data |returns={{type|string}} serializedData |desc...")
Function textutils.serializeJSON | |
Returns a JSON representation of the data data in a form of a string, mainly for command usage. There is a special key in textutils table: textutils.EMPTY_ARRAY which represents an empty JSON array ( [ ] ). You can use it to serialize an empty JSON array inside, for example a table.
| |
Syntax | textutils.serializeJSON(table/string/number/boolean data) |
Returns | string serializedData |
Part of | ComputerCraft |
API | textutils |
Examples
Example | |
Serializes a table into JSON and prints it. | |
Code |
local myTable = { key = "value", anotherKey = true, number = 5, array = {1, 2, 3}, emptyArray = textutils.EMPTY_ARRAY } print( textutils.serializeJSON( myTable ) ) |
Output | {"key":"value","anotherKey":true,"number":5,"array":[1,2,3],"emptyArray":[]} |