FromJSON: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 14: Line 14:


==Example==  
==Example==  
 
This should make data equal: {1="cat", 2="mouse", 3=5, 4=null, 5={cat=5, mouse=1}} (untested)
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--Needs example
local data = fromJSON("[\"cat\", \"mouse\", 5, null, {cat:5, mouse:1}]")
</syntaxhighlight>
</syntaxhighlight>



Revision as of 14:15, 20 December 2007

This function parses a JSON formatted string into variables.

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

See Also