I don't know how to use erlang function term_to_json and json_to_term, do I need to install some plugins or the moudule of those functions are not "erlang"?
-
1you should take a look at this SQ question: http://stackoverflow.com/questions/1652296/erlang-json-libraries-serialization-performance – Anthony Kong Aug 27 '14 at 12:26
2 Answers
There is currently no such function in Erlang. There is Erlang Enhancement Proposal, which describes this:
http://www.erlang.org/eeps/eep-0018.html
but it is not yet part of the language. Fortunately, there is quite a few libraries, that solve the problem. I can recommend:
https://github.com/talentdeficit/jsx
It is actively maintained, battle tested and used internally in bigger projects like Chicago Boss.

- 9,129
- 1
- 27
- 51
As @tkowal has said, term_to_json
and json_to_term
do not exist in the erlang
module.
If you are looking for a simple way to encode and decode erlang terms to and from binaries or strings you can use term_to_binary/1
or term_to_binary/2
. These two functions will encode erlang terms to binaries, which can be stored or sent over the network, to be later decoded again by erlang.

- 4,648
- 4
- 35
- 67