今天安装 erlang-jiffy 把握逼疯,不过最后还是成功了。
错误避免:
- rebar只能再英文目录下运行,如果编译jiffy的目录中有中文或其它unicode字符,将会出错
- 从git release 下下来的编译出错,具体原因不明
解决方案,从git 克隆下来最新代码进行编译
> git clone https://github.com/davisp/jiffy.git
>cd jiffy
>make
最后将整个 jiffy目录复制到erlang的lib目录下,或自己添加搜索路径即可,下面是一些简单测试:
4> Term = jiffy:decode("{\"head\":{\"status\":\"result\",\"type\":\"command\",\"timestamp\":2342435234},\"body\":{}}").
{[{<<"head">>, {[{<<"status">>,<<"result">>}, {<<"type">>,<<"command">>}, {<<"timestamp">>,2342435234}]}}, {<<"body">>,{[]}}]}5> Json = jiffy:encode(Term).<<"{\"head\":{\"status\":\"result\",\"type\":\"command\",\"timestamp\":2342435234},\"body\":{}}">>6> io:format("~s",[Json]).{"head":{"status":"result","type":"command","timestamp":2342435234},"body":{}}ok