summaryrefslogtreecommitdiff
path: root/Data/BuiltIn/Libraries/json4lua/README.md
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-15 11:54:17 +0800
committerchai <chaifix@163.com>2021-11-15 11:54:17 +0800
commit30f2f46474bf4eda5f10d4c64a07cde01d469f66 (patch)
tree6ff2ed3262037b3c9bae2d2b9059a1d65773f31c /Data/BuiltIn/Libraries/json4lua/README.md
parent4c36bed53fe63ae6056730b3ecad2573f03d88f8 (diff)
*rename DefaultContent -> BuiltIn
Diffstat (limited to 'Data/BuiltIn/Libraries/json4lua/README.md')
-rw-r--r--Data/BuiltIn/Libraries/json4lua/README.md52
1 files changed, 52 insertions, 0 deletions
diff --git a/Data/BuiltIn/Libraries/json4lua/README.md b/Data/BuiltIn/Libraries/json4lua/README.md
new file mode 100644
index 0000000..b4f8015
--- /dev/null
+++ b/Data/BuiltIn/Libraries/json4lua/README.md
@@ -0,0 +1,52 @@
+# json4lua
+JSON and JSONRPC for Lua
+
+# Installation #
+```
+luarocks install --server=http://rocks.moonscript.org/manifests/amrhassan --local json4Lua
+```
+
+# JSON Usage #
+
+## Encoding ##
+
+```lua
+json = require('json')
+print(json.encode({ 1, 2, 'fred', {first='mars',second='venus',third='earth'} }))
+```
+```json
+[1,2,"fred", {"first":"mars","second":"venus","third":"earth"}]
+```
+
+## Decoding ##
+
+```lua
+json = require("json")
+testString = [[ { "one":1 , "two":2, "primes":[2,3,5,7] } ]]
+decoded = json.decode(testString)
+table.foreach(decoded, print)
+print ("Primes are:")
+table.foreach(decoded.primes,print)
+```
+```
+one 1
+two 2
+primes table: 0032B928
+Primes are:
+1 2
+2 3
+3 5
+4 7
+```
+
+# JSONRPC Usage #
+```lua
+json = require('json')
+require("json.rpc")
+server = json.rpc.proxy("http://jsolait.net/testj.py")
+result, error = server.echo('Test echo!')
+print(result)
+```
+```
+Test echo!
+```