Undefined function maps: to_json / 1

This is one of the things I learned from Programming Erlang, 2nd Ed , but doesn't seem to work with the 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 is wrong here?

+8
erlang
source share
1 answer

Programming Erlang, 2nd Ed was written before maps were introduced in release 17 (as an experimental feature), and it seems that the author of the book, Joe Armstrong, was too optimistic about them. However, some of the proposed functionality and syntax have not yet been implemented (or never will be).

Fortunately, there are JSON parsers for erlang that support maps, check:

+18
source share

All Articles