【发布时间】:2016-11-03 11:37:45
【问题描述】:
我正在使用 HTTPoison 获取 elixir 指南网站,然后使用 Floki 对其进行解析以构建 HTML 2 Jupyter Notebook 转换器(使用 Markdown 进行描述)。我必须输入`反引号。 \u0060 用于代码突出显示,到目前为止有效。我有一些地方使用字符串插值"#{Floki.text(childs_nodes)}" 和其他地方Enum.join "" 来处理和从HTML 转换为Markdown。
转换后的结果按照 jupyter notebook 格式存储在地图中。当我调用Poison.encode notebook 时,我收到一个错误,因为代码点已经消失。我尝试了不同的方法,但还不知道问题出在哪里。
任何提示我在处理文本时做错了什么?这是一个例外:
** (Poison.EncodeError) unable to encode value: {:source, ["Elixir also provides `Port`, `Reference` and `PID` as data types (usually used in process communication), and we will take a quick look at them when talking about processes. For now, let’s take a look at some of the basic operators that go with our basic types."]}
lib/poison/encoder.ex:377: Poison.Encoder.Any.encode/2
lib/poison/encoder.ex:255: anonymous fn/3 in Poison.Encoder.List.encode/3
lib/poison/encoder.ex:256: Poison.Encoder.List."-encode/3-lists^foldr/2-1-"/3
lib/poison/encoder.ex:256: Poison.Encoder.List.encode/3
lib/poison.ex:41: Poison.encode!/2
(guide2nb) lib/cli.ex:27: CLI.process/1
(elixir) lib/kernel/cli.ex:76: anonymous fn/3 in Kernel.CLI.exec_fun/2
【问题讨论】:
-
您尝试编码的值看起来不像地图,而是元组。在此处粘贴您的原始值(和/或尝试对其进行编码的代码)
-
Poison 不编码元组。
标签: elixir elixir-poison