G.KeyValuesToTablePreserveOrder

From GMod Wiki

Revision as of 13:50, 19 August 2011 by TheFreeman193 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax KeyValuesToTablePreserveOrder( String text (key-values) )
Where is this used?
Description:
Like KeyValuesToTable, but returns a table of tables, each holding one key and it's associated value.
Returns: Table
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.KeyValuesToTablePreserveOrder]G.KeyValuesToTablePreserveOrder [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionConverts a key-value string to a table, preserving the key order.
Used onNewerShared.png
Code
 
local key_value_string = [["0"
{
	"health"       "123.3"
	"name"         "Billy"
	"extra"
	{
		"param1"    "234"
		"param2"    "Balloon"
		"param3"    "true"
	}
}]]
 
local my_table = KeyValuesToTablePreserveOrder( key_value_string )
 
PrintTable(my_table)
OutputTo Console:
1:
		Key	=	health
		Value	=	123.30000305176
2:
		Key	=	name
		Value	=	Billy
3:
		Key	=	extra
		Value:
				1:
						Key	=	param1
						Value	=	234
				2:
						Key	=	param2
						Value	=	Balloon
				3:
						Key	=	param3
						Value	=	true


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox