Difference between revisions of "Json"
From GiderosMobile
|  (remove language stuff) | m (Text replacement - "</source>" to "</syntaxhighlight>") | ||
| (One intermediate revision by the same user not shown) | |||
| Line 9: | Line 9: | ||
| === Example === | === Example === | ||
| '''Gets user's geolocation''' | '''Gets user's geolocation''' | ||
| − | < | + | <syntaxhighlight lang="lua"> | 
| require('json') | require('json') | ||
| Line 19: | Line 19: | ||
| 	print(receivedTable.timezone) | 	print(receivedTable.timezone) | ||
| end) | end) | ||
| − | </ | + | </syntaxhighlight> | 
| {|- | {|- | ||
Latest revision as of 14:30, 13 July 2023
Supported platforms: 






Available since: Gideros 2013.09
Description
Provides Lua table serialization and deserialization to and from string in json format.
Example
Gets user's geolocation
require('json')
local loader = UrlLoader.new("http://ip-api.com/json")
loader:addEventListener(Event.COMPLETE, function(event)
	local receivedTable=json.decode(event.data)
	print(receivedTable.countryCode)
	print(receivedTable.timezone)
end)
| Methodsjson.decode returns Lua table from provided json encoded string | EventsConstants | 
