This is one of the things I learned from Programming Erlang, 2nd Ed
, but doesn't seem to work on shell
$ erl
Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Eshell V6.2 (abort with ^G)
1> Dic = #{b => 1, a => 2}.
#{a => 2,b => 1}
2> maps:to_json(Dic).
** exception error: undefined function maps:to_json/1
3>
What's wrong here?
Programming Erlang, 2nd Ed
was written before maps were introduced in release 17 (as experimental feature) and it seems that author of book, Joe Armstrong was too optimistic about them. Still some of proposed functionality and syntax is not yet implemented (or never will be).
Luckily, there are JSON parsers for erlang which support maps, check:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With