ToJSON: Difference between revisions
Jump to navigation
Jump to search
OpenIDUser32 (talk | contribs) No edit summary |
m (Labeled as a server-client function) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server client function}} | ||
{{New feature/item|3.0120|1.2|| | {{New feature/item|3.0120|1.2|| | ||
Available client side in 1.2 and onwards | Available client side in 1.2 and onwards |
Revision as of 02:10, 19 December 2011
Available client side in 1.2 and onwards This function converts one or more variables into a JSON encoded string. You can use this to store the data and then load it again using fromJSON.
Syntax
string toJSON( var arguments ... )
Required Arguments
- arguments: A list of arguments of any type. Arguments that are elements will be stored as element IDs that are liable to change between sessions. As such, do not save elements across sessions as you will get unpredictable results.
Returns
Returns a JSON formatted string.
Example
This example shows how you can encode an array. The string json should equal "["cat", "mouse", {cat:"hungry",mouse:"food"}]" after executed.
local json = toJSON ( "cat", "mouse", {cat="hungry",mouse="food"} )
Requirements
This template will be deleted.
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown