且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Elixir中将Base64字符串转换为映射

更新时间:2022-06-11 05:34:30

您需要使用JSON库.有几种,一种是常用的一种是毒物(在

You need to use a JSON library. There are several, one commonly used one is Poison (there are others on hex):

string |> Base.url_decode64 |> Poison.decode!

这使用 Poison.decode!/2 函数.

每当我使用时,我都希望将其别名为JSON,以便在我的整个代码中都没有对Poison的引用:

Whenever I use I like to alias it as JSON so that I don't have references to Poison throughout my code:

alias Poison, as: JSON
string |> Base.url_decode64 |> JSON.decode!