blob: 36497da28ac0fbbbac34d3c29163686376ccc102 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
--[[
JSON4Lua example script.
Demonstrates the simple functionality of the json module.
]]--
json = require('json')
-- Object to JSON encode
test = {
one='first',two='second',three={2,3,5}
}
jsonTest = json.encode(test)
print('JSON encoded test is: ' .. jsonTest)
-- Now JSON decode the json string
result = json.decode(jsonTest)
print ("The decoded table result:")
table.foreach(result,print)
print ("The decoded table result.three")
table.foreach(result.three, print)
|