Permalink
Browse files

Use jiffy as the (default) JSON lib.

This requires a new rebar which cannot be counted on to be in e.g., homebrew.
  • Loading branch information...
1 parent dc77578 commit f0fab101c23b021494d5adb370fd7a6e877cfc76 @squaremo squaremo committed Oct 27, 2011
Showing with 16 additions and 11 deletions.
  1. +7 −7 Makefile
  2. BIN rebar
  3. +2 −2 rebar.config
  4. +1 −1 src/sockjs.app.src
  5. +6 −1 src/sockjs_util.erl
View
@@ -1,21 +1,21 @@
-JSON=eep0018
+JSON=jiffy
HTTP=cowboy
.PHONY: all deps test test-prep clean distclean
all: deps deps/$(HTTP)
make -C deps/$(HTTP)
- rebar compile
+ ./rebar compile
deps:
- -rebar get-deps
+ -./rebar get-deps
# git:// URLs don't work behind some proxies. Grr.
sed -i='' 's|git:|https:|g' deps/cowboy/rebar.config
- rebar get-deps
+ ./rebar get-deps
test: test-prep all
- erl -pa ebin deps/$(HTTP)/ebin deps/$(HTTP)/deps/*/ebin \
- -pa deps/json/ebin -sockjs json_impl $(JSON) \
+ erl -pa ebin deps/*/ebin \
+ -sockjs json_impl $(JSON) \
-sockjs http_impl $(HTTP) \
-run sockjs_test
@@ -39,7 +39,7 @@ deps/misultin:
git clone -b dev https://github.com/ostinelli/misultin.git
clean::
- rebar clean
+ ./rebar clean
rm -rf priv/www
distclean::
View
BIN rebar
Binary file not shown.
View
@@ -1,6 +1,6 @@
{deps, [
{cowboy, ".*",
{git, "https://github.com/extend/cowboy.git", {branch, "master"}}},
- {json, ".*",
- {git, "https://github.com/davisp/eep0018.git", {branch, "master"}}}
+ {jiffy, "0.2.0",
+ {git, "https://github.com/davisp/jiffy.git", {tag, "0.2.0"}}}
]}.
View
@@ -11,5 +11,5 @@
{env, [{sockjs_url, "/lib/sockjs.js"},
{heartbeat_ms, 25000},
{session_close_ms, 5000},
- {json_impl, mochijson2}]}
+ {json_impl, jiffy}]}
]}.
View
@@ -1,7 +1,7 @@
-module(sockjs_util).
-export([encode/1, encode/2, decode/1, encode_list/1]).
--export([mochijson2/2, eep0018/2]).
+-export([mochijson2/2, eep0018/2, jiffy/2]).
encode_list([{close, {Code, Reason}}]) ->
encode(<<"c">>, [Code, list_to_binary(Reason)]);
@@ -32,3 +32,8 @@ mochijson2(JSON, decode) ->
eep0018(Thing, encode) -> {ok, JSON} = json:encode(Thing), JSON;
eep0018(JSON, decode) -> json:decode(JSON).
+
+jiffy(Thing, encode) ->
+ iolist_to_binary(jiffy:encode(Thing));
+jiffy(JSON, decode) ->
+ {ok, jiffy:decode(JSON)}.

0 comments on commit f0fab10

Please sign in to comment.