diff options
author | chai <chaifix@163.com> | 2021-10-26 11:32:46 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-26 11:32:46 +0800 |
commit | 0549b1e5a8a3132005e275d6026db8003cb067d2 (patch) | |
tree | f0d7751ec32ecf5c4d23997fa0ffd3450a5a755a /Data/DefaultContent/Libraries/json4lua/examples/example.lua | |
parent | 32345800737b668011a87328cd3dcce59ec2934c (diff) |
*rename folder
Diffstat (limited to 'Data/DefaultContent/Libraries/json4lua/examples/example.lua')
-rw-r--r-- | Data/DefaultContent/Libraries/json4lua/examples/example.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Data/DefaultContent/Libraries/json4lua/examples/example.lua b/Data/DefaultContent/Libraries/json4lua/examples/example.lua new file mode 100644 index 0000000..36497da --- /dev/null +++ b/Data/DefaultContent/Libraries/json4lua/examples/example.lua @@ -0,0 +1,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)
|