Erlang 安装使用rfc4627

环境: Ubuntu 14.04

编译

git clone git://github.com/tonyg/erlang-rfc4627.git

cd erlang-rfc4627/

make all

获取erlang library路径

jerry@iZ28ktvewfwZ:~$ erl
Erlang R16B03 (erts-5.10.4) [source] [64-bit] [async-threads:10] [kernel-poll:false]

Eshell V5.10.4 (abort with ^G)
1> code:get_path().
[“.”,”/usr/lib/erlang/lib/kernel-2.16.4/ebin”,
“/usr/lib/erlang/lib/stdlib-1.19.4/ebin”,
“/usr/lib/erlang/lib/xmerl-1.3.5/ebin”,
“/usr/lib/erlang/lib/wx-1.1.1”,
[…]|…]
2>

将文件夹拷贝到相应目录下

sudo cp -R erlang-rfc4627/ /usr/lib/erlang/lib/

 
测试使用

jerry@iZ28ktvewfwZ:~$ erl
Erlang R16B03 (erts-5.10.4) [source] [64-bit] [async-threads:10] [kernel-poll:false]

Eshell V5.10.4 (abort with ^G)
1> O = rfc4627:encode({obj, [{name, hideto}, {age, 23}]}).
“{\”name\”:\”hideto\”,\”age\”:23}”
2>