未定义的函数映射:to_json / 1 [英] undefined function maps:to_json/1

查看:71
本文介绍了未定义的函数映射:to_json / 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从编程Erlang,第二版中学到的东西之一,但似乎不适用于shell

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> 

这里出什么问题了?

推荐答案

编程Erlang,第二版写在地图版本17 中引入(作为实验专题),而这本书的作者乔·阿姆斯特朗似乎对它们太乐观了。仍未实现(或永远不会实现)一些建议的功能和语法。

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).

幸运的是,有支持erlang的JSON解析器,支持地图,请检查:

Luckily, there are JSON parsers for erlang which support maps, check:

  • jiffy
  • jsx

这篇关于未定义的函数映射:to_json / 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆