FromJSON: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local data = fromJSON("[\"cat\", \"mouse\", 5, null, {cat:5, mouse:1}]") | local data = fromJSON("[\"cat\", \"mouse\", 5, null, {cat:5, mouse:1}]") | ||
</syntaxhighlight> | |||
==Example 2== | |||
<syntaxhighlight lang="lua"> | |||
local name, weapon, ammo = fromJSON("[\"Desert Eagle\", 24, 147]") | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Server_functions}} | {{Server_functions}} |
Revision as of 18:46, 13 June 2010
This function parses a JSON formatted string into variables. You can use toJSON to encode variables into a JSON string that can be read by this function.
Syntax
var fromJSON ( string json )
Required Arguments
- json: A JSON formatted string
Returns
Returns variables read from the JSON string.
Example
This should make data equal: {1="cat", 2="mouse", 3=5, 4=null, 5={cat=5, mouse=1}} (untested)
local data = fromJSON("[\"cat\", \"mouse\", 5, null, {cat:5, mouse:1}]")
Example 2
local name, weapon, ammo = fromJSON("[\"Desert Eagle\", 24, 147]")
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown