Skip to content

Commit 0ab2c74

Browse files
committed
Complette event parser
1 parent 6731e67 commit 0ab2c74

File tree

6 files changed

+613
-52
lines changed

6 files changed

+613
-52
lines changed

README.md

+43-41
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ Works with binaries as strings, arrays as lists and only knows how to decode UTF
55
JSONX IS VERY FAST!
66
------------------
77

8-
Check out a benchmark [si14/erl_json_test](https://github.com/si14/erl_json_test) and record encoding tests in `/benchmarks/test_encode_records.erl`
8+
Check out a benchmark [si14/erl_json_test](https://github.com/si14/erl_json_test) or
9+
[davisp/erljson_bench](https://github.com/davisp/erljson_bench) and
10+
record encoding tests in `/benchmarks/test_encode_records.erl`
11+
12+
INSTALLATION and DOCUMENTATION
13+
------------------------------
14+
15+
* cd jsonx
16+
* make
17+
* make doc
18+
* firefox doc/index.html&
919

1020
JSONX can encode and decode Erlang records!
1121
-------------------------------------------
@@ -86,46 +96,10 @@ nonstrict_decoder1() ->
8696
```
8797

8898

89-
Decode (JSON -> Erlang)
90-
----------------------
91-
92-
null :-> null
93-
true :-> true
94-
false :-> false
95-
"string" :-> <<"binary">>
96-
[1, 2.3, []] :-> [1, 2.3, []]
97-
{"this": "json"} :-> {[{<<"this">>: <<"json">>}]} %% default eep18
98-
{"this": "json"} :-> [{<<"this">>: <<"json">>}] %% optional proplist
99-
{"this": "json"} :-> {struct, [{<<"this">>: <<"json">>}]} %% optional struct
100-
JSONObject :-> #rec{...} %% decoder must be predefined
101-
102-
Encode (Erlang -> JSON)
103-
-----------------------
104-
105-
null :-> null
106-
true :-> true
107-
false :-> false
108-
atom :-> "atom"
109-
<<"str">> :-> "str"
110-
[1, 2.99] :-> [1, 2.99]
111-
{struct, [{<<"this">>: <<"json">>}]} :-> {"this": "json"}
112-
[{<<"this">>: <<"json">>}] :-> {"this": "json"}
113-
{[{<<"this">>: <<"json">>}]} :-> {"this": "json"}
114-
{json, IOList} :-> `iolist_to_binary(IOList)` %% include with no validation
115-
#rec{...} :-> JSONObject %% encoder must be predefined
116-
117-
INSTALLATION and DOCUMENTATION
118-
------------------------------
119-
120-
* cd jsonx
121-
* make
122-
* make doc
123-
* firefox doc/index.html&
124-
12599
Examples encoding JSON
126100
----------------------
127101

128-
~~~~~
102+
```erlang
129103
1> jsonx:encode([1, 2.3, true, false, null, atom, <<"string">>, []]).
130104
<<"[1,2.3,true,false,null,\"atom\",\"string\",[]]">>
131105

@@ -140,12 +114,12 @@ Examples encoding JSON
140114
%% Object as eep18 propsal
141115
4> jsonx:encode( {[{name, <<"Ivan">>}, {age, 33}, {phones, [3332211, 4443322]}]} ).
142116
<<"{\"name\":\"Ivan\",\"age\":33,\"phones\":[3332211,4443322]}">>
143-
~~~~~
117+
```
144118

145119
Examples decoding JSON
146120
----------------------
147121

148-
~~~~~
122+
```erlang
149123
1> jsonx:decode(<<"{\"name\":\"Ivan\",\"age\":33,\"phones\":[3332211,4443322]}">>).
150124
{[{<<"name">>,<<"Ivan">>},
151125
{<<"age">>,33},
@@ -165,4 +139,32 @@ Examples decoding JSON
165139
{struct,[{<<"name">>,<<"Ivan">>},
166140
{<<"age">>,33},
167141
{<<"phones">>,[3332211,4443322]}]}
168-
~~~~~
142+
```
143+
144+
Mapping (JSON -> Erlang)
145+
----------------------
146+
147+
null :-> null
148+
true :-> true
149+
false :-> false
150+
"string" :-> <<"binary">>
151+
[1, 2.3, []] :-> [1, 2.3, []]
152+
{"this": "json"} :-> {[{<<"this">>: <<"json">>}]} %% default eep18
153+
{"this": "json"} :-> [{<<"this">>: <<"json">>}] %% optional proplist
154+
{"this": "json"} :-> {struct, [{<<"this">>: <<"json">>}]} %% optional struct
155+
JSONObject :-> #rec{...} %% decoder must be predefined
156+
157+
Mapping (Erlang -> JSON)
158+
-----------------------
159+
160+
null :-> null
161+
true :-> true
162+
false :-> false
163+
atom :-> "atom"
164+
<<"str">> :-> "str"
165+
[1, 2.99] :-> [1, 2.99]
166+
{struct, [{<<"this">>: <<"json">>}]} :-> {"this": "json"}
167+
[{<<"this">>: <<"json">>}] :-> {"this": "json"}
168+
{[{<<"this">>: <<"json">>}]} :-> {"this": "json"}
169+
{json, IOList} :-> `iolist_to_binary(IOList)` %% include with no validation
170+
#rec{...} :-> JSONObject %% encoder must be predefined

0 commit comments

Comments
 (0)