From f2dcd16fc72e2f10c9504897bacf5c4c2ecff516 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 20 Oct 2021 19:36:15 +0800 Subject: +lua libs --- .../Libraries/json4lua/examples/example.lua | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Resources/DefaultContent/Libraries/json4lua/examples/example.lua (limited to 'Resources/DefaultContent/Libraries/json4lua/examples/example.lua') diff --git a/Resources/DefaultContent/Libraries/json4lua/examples/example.lua b/Resources/DefaultContent/Libraries/json4lua/examples/example.lua new file mode 100644 index 0000000..36497da --- /dev/null +++ b/Resources/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) -- cgit v1.1-26-g67d0