Skip to content

Commit 7479a6f

Browse files
committed
Create README.md
1 parent 4e4f7ab commit 7479a6f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# json4lua
2+
JSON and JSONRPC for Lua
3+
4+
# Installation #
5+
```
6+
luarocks install --server=http://rocks.moonscript.org/manifests/amrhassan --local json4Lua
7+
```
8+
9+
# JSON Usage #
10+
11+
## Encoding ##
12+
13+
```lua
14+
require('json')
15+
print(json.encode({ 1, 2, 'fred', {first='mars',second='venus',third='earth'} }))
16+
```
17+
```json
18+
[1,2,"fred", {"first":"mars","second":"venus","third","earth"}]
19+
```
20+
21+
## Decoding ##
22+
23+
```lua
24+
require("json")
25+
testString = [[ { "one":1 , "two":2, "primes":[2,3,5,7] } ]]
26+
decoded = json.decode(testString)
27+
table.foreach(decoded, print)
28+
print ("Primes are:")
29+
table.foreach(o.primes,print)
30+
```
31+
```
32+
one 1
33+
two 2
34+
primes table: 0032B928
35+
Primes are:
36+
1 2
37+
2 3
38+
3 5
39+
4 7
40+
```
41+
42+
# JSONRPC Usage #
43+
```lua
44+
require("json.rpc")
45+
server = json.rpc.proxy("http://jsolait.net/testj.py")
46+
result, error = server.echo('Test echo!')
47+
print(result)
48+
```
49+
```
50+
Test echo!
51+
```

0 commit comments

Comments
 (0)