Maxximiliann
Poison.decode! - (MatchError) no match of right hand side value
(Please note: Exlir/Poison Experience Level: Beginner so please Eli5)
Given:
iex(1)> results = HTTPoison.get!("https://nodes.wavesnodes.com/assets/balance/3PDh3tDWWXmJtfoqRkf1p9PnZAHmBLcWXFW")
%HTTPoison.Response{
body: "{\"address\":\"3PDh3tDWWXmJtfoqRkf1p9PnZAHmBLcWXFW\",\"balances\":[{\"assetId\":\"6GQkwHGyd769EghKQ6qXhAHG55JyaFjK7VGWEKSSg4Z8\",\"balance\":100000000,\"reissuable\":false,\"minSponsoredAssetFee\":null,\"sponsorBalance\":null,\"quantity\":2099443248805633,\"issueTransaction\":{\"senderPublicKey\":\"2TW1p199hYspTxt3hZc2wm9VGGDE4qFxyY2Th1HoFVww\",\"quantity\":2100000000000000,\"fee\":100000000,\"description\":\"\\\"Progression\\\" conception intelligente de jeton innovant qui se limite à évaluer 0,0001 de vagues par jour, les commandes sont limitées à 100 minutes pour stimuler la progression quotidienne.\\n\\\"Progression\\\" innovative token intelligent design that is limited to valuing 0.0001 of waves per day, orders are limited to 100 minutes to stimulate daily progression.\",\"type\":3,\"version\":2,\"reissuable\":false,\"script\":\"base64:AQQAAAALc3RhcnRIZWlnaHQAAAAAAAAVWMoEAAAACnN0YXJ0UHJpY2UAAAAAAAAAJxAEAAAACGludGVydmFsCQAAaAAAAAIAAAAAAAAAABgAAAAAAAAAADwEAAAAA2V4cAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAADwAAAAAAAAAA+gEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNFeGNoYW5nZVRyYW5zYWN0aW9uBAAAAAFlBQAAAAckbWF0Y2gwBAAAAARkYXlzCQAAaQAAAAIJAABlAAAAAgUAAAAGaGVpZ2h0BQAAAAtzdGFydEhlaWdodAUAAAAIaW50ZXJ2YWwDAwMJAABnAAAAAggFAAAAAWUAAAAFcHJpY2UJAABoAAAAAgUAAAAKc3RhcnRQcmljZQkAAGQAAAACAAAAAAAAAAABCQAAaAAAAAIFAAAABGRheXMFAAAABGRheXMJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEICAgFAAAAAWUAAAAJc2VsbE9yZGVyAAAACWFzc2V0UGFpcgAAAApwcmljZUFzc2V0BwkAAGcAAAACBQAAAANleHAJAABlAAAAAggIBQAAAAFlAAAACXNlbGxPcmRlcgAAAApleHBpcmF0aW9uCAgFAAAAAWUAAAAJc2VsbE9yZGVyAAAACXRpbWVzdGFtcAcJAABnAAAAAgUAAAADZXhwCQAAZQAAAAIICAUAAAABZQAAAAhidXlPcmRlcgAAAApleHBpcmF0aW9uCAgFAAAAAWUAAAAIYnV5T3JkZXIAAAAJdGltZXN0YW1wBwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPQnVyblRyYW5zYWN0aW9uBAAAAAJ0eAUAAAAHJG1hdGNoMAYGF8/Q+A==\",\"sender\":\"3PMQ27yBjrshdxGmFjTZHY6taN17saQyfM8\",\"feeAssetId\":null,\"chainId\":87,\"proofs\":[\"2YAgh7QQ49oFqgTfDYT5mh58xcqspR2kQJrpiLYRTtyPrtakUuYjVyt9ejr5m3suF7FZUhze1ZmXU1Ry6yJdWheV\"],\"assetId\":\"6GQkwHGyd769EghKQ6qXhAHG55JyaFjK7VGWEKSSg4Z8\",\"decimals\":8,\"name\":\"Progression\",\"id\":\"6GQkwHGyd769EghKQ6qXhAHG55JyaFjK7VGWEKSSg4Z8\",\"timestamp\":1550319832173}},{\"assetId\":\"51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze\",\"balance\":6,\"reissuable\":false,\"minSponsoredAssetFee\":10000,\"sponsorBalance\":90323001,\"quantity\":9999999886689962,\"issueTransaction\":{\"senderPublicKey\":\"FCfKDQiCaNruTAj984WCrQLHS1j1c8Fv5JzgKswgAhoy\",\"quantity\":10000000000000000,\"fee\":100000000,\"description\":\"TOR Corporation\\nОфициальная чат-группа монет TOR https://t.me/projecttorcoin \\nWhite paper https://docs.google.com/document/d/1LJfo6X82cAjLI4tahkVN-jR_GU8a4d2aZ_tFtXP4yYI/edit?usp=sharing Дорожная карта https://docs.google.com/document/d/1qBheIvDO3KSfyQnWQdbwUBKZtalaILhCak03fJlQRTk/edit?usp=sharing\",\"type\":3,\"version\":2,\"reissuable\":false,\"script\":null,\"sender\":\"3P287ZEpVU14SAr4jhCF58fZPzfkQv4LXqm\",\"feeAssetId\":null,\"chainId\":87,\"proofs\":[\"4f7ZzQ5ZgZskxnCDhU4RKx6MWCHNVrnJs8hKRfGWX35aSyJtcJqrQuUaahrqcAnYU8dpDq8rRUvTtwa6VhcEEx7v\"],\"assetId\":\"51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze\",\"decimals\":6,\"name\":\"TORCorp\",\"id\":\"51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze\",\"timestamp\":1541398865252}},{\"assetId\":\"GAAZu8fsWfrZBFgweMMAFEcjrW9CFRxPEqmGcbSGWVDF\",\"balance\":300000000,\"reissuable\":false,\"minSponsoredAssetFee\":null,\"sponsorBalance\":null,\"quantity\":4999999200000000,\"issueTransaction\":{\"senderPublicKey\":\"jYTtcsLgDD5NcoDHUAnHLdC9PjeSwyjxFysptotgHjq\",\"quantity\":10000000000000000,\"fee\":100000000,\"description\":\"K975 Token\",\"type\":3,\"version\":2,\"reissuable\":false,\"script\":null,\"sender\":\"3PMSXKE9AqLMw2Yh5nTscm2DSJP677hf2QJ\",\"feeAssetId\":null,\"chainId\":87,\"proofs\":[\"2GPLuTFZFb8bLKV1AJ15VUtjHpmMcvXo8nNmi9F5pwdptgudiGXwU2efM5BFCP2FvK7zAdR5zQPBguJFY4kyUqXd\"],\"assetId\":\"GAAZu8fsWfrZBFgweMMAFEcjrW9CFRxPEqmGcbSGWVDF\",\"decimals\":8,\"name\":\"K975\",\"id\":\"GAAZu8fsWfrZBFgweMMAFEcjrW9CFRxPEqmGcbSGWVDF\",\"timestamp\":1568118516242}},{\"assetId\":\"2rdZt8RxEftbmz34HLBd7Au2icyScgAe5YoipeT7GwK2\",\"balance\":1,\"reissuable\":false,\"minSponsoredAssetFee\":null,\"sponsorBalance\":null,\"quantity\":49999986,\"issueTransaction\":{\"senderPublicKey\":\"StYAY98BDsSDvhMRFauKxn5pWEcD6KxnRnvPDbtceZ" <> ...,
headers: [
{"Date", "Sat, 12 Oct 2019 20:01:32 GMT"},
{"Content-Type", "application/json"},
{"Transfer-Encoding", "chunked"},
{"Connection", "keep-alive"},
{"Set-Cookie",
"__cfduid=d7522b5d559f3952392299b4e3c07a2cb1570910492; expires=Sun, 11-Oct-20 20:01:32 GMT; path=/; domain=.wavesnodes.com; HttpOnly"},
{"Vary", "Accept-Encoding"},
{"Access-Control-Allow-Origin", "*"},
{"Access-Control-Allow-Credentials", "true"},
{"Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE"},
{"Access-Control-Allow-Headers",
"DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,signature,timestamp"},
{"Access-Control-Expose-Headers", "Content-Length,Content-Range"},
{"Backend", "ca-2"},
{"Content-Security-Policy",
"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' online.swagger.io"},
{"X-Frame-Options", "DENY"},
{"X-XSS-Protection", "0"},
{"X-Content-Type-Options", "nosniff"},
{"Referrer-Policy", "unsafe-url"},
{"CF-Cache-Status", "DYNAMIC"},
{"Set-Cookie",
"AWSALB=3/o7aRqBwecPhGPjflqgWoA5R8nviB4AuiJ+hzmjke8QIkv4rXRCeAGXxGHYs4OTYS+C/EfEUc83sWOSdFdpDe7ugPrSkX3GqeX4+BBNCnpy510HP/sehtLLBkim; Expires=Sat, 19 Oct 2019 20:01:32 GMT; Path=/"},
{"Set-Cookie",
"__cflb=3256034178; path=/; expires=Sun, 13-Oct-19 19:01:32 GMT; HttpOnly"},
{"Expect-CT",
"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""},
{"Server", "cloudflare"},
{"CF-RAY", "524baa8f68e9c7c5-DEN"}
],
request: %HTTPoison.Request{
body: "",
headers: [],
method: :get,
options: [],
params: %{},
url: "https://nodes.wavesnodes.com/assets/balance/3PDh3tDWWXmJtfoqRkf1p9PnZAHmBLcWXFW"
},
request_url: "https://nodes.wavesnodes.com/assets/balance/3PDh3tDWWXmJtfoqRkf1p9PnZAHmBLcWXFW",
status_code: 200
}
Why does this fail?
iex(2)> %{data: items} = Poison.decode!(results.body, keys: :atoms)
** (MatchError) no match of right hand side value: %{address: "3PDh3tDWWXmJtfoqRkf1p9PnZAHmBLcWXFW", balances: [%{assetId: "6GQkwHGyd769EghKQ6qXhAHG55JyaFjK7VGWEKSSg4Z8", balance: 100000000, issueTransaction: %{assetId: "6GQkwHGyd769EghKQ6qXhAHG55JyaFjK7VGWEKSSg4Z8", chainId: 87, decimals: 8, description: "\"Progression\" conception intelligente de jeton innovant qui se limite à évaluer 0,0001 de vagues par jour, les commandes sont limitées à 100 minutes pour stimuler la progression quotidienne.\n\"Progression\" innovative token intelligent design that is limited to valuing 0.0001 of waves per day, orders are limited to 100 minutes to stimulate daily progression.", fee: 100000000, feeAssetId: nil, id: "6GQkwHGyd769EghKQ6qXhAHG55JyaFjK7VGWEKSSg4Z8", name: "Progression", proofs: ["2YAgh7QQ49oFqgTfDYT5mh58xcqspR2kQJrpiLYRTtyPrtakUuYjVyt9ejr5m3suF7FZUhze1ZmXU1Ry6yJdWheV"], quantity: 2100000000000000, reissuable: false, script: "base64:AQQAAAALc3RhcnRIZWlnaHQAAAAAAAAVWMoEAAAACnN0YXJ0UHJpY2UAAAAAAAAAJxAEAAAACGludGVydmFsCQAAaAAAAAIAAAAAAAAAABgAAAAAAAAAADwEAAAAA2V4cAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAADwAAAAAAAAAA+gEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNFeGNoYW5nZVRyYW5zYWN0aW9uBAAAAAFlBQAAAAckbWF0Y2gwBAAAAARkYXlzCQAAaQAAAAIJAABlAAAAAgUAAAAGaGVpZ2h0BQAAAAtzdGFydEhlaWdodAUAAAAIaW50ZXJ2YWwDAwMJAABnAAAAAggFAAAAAWUAAAAFcHJpY2UJAABoAAAAAgUAAAAKc3RhcnRQcmljZQkAAGQAAAACAAAAAAAAAAABCQAAaAAAAAIFAAAABGRheXMFAAAABGRheXMJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEICAgFAAAAAWUAAAAJc2VsbE9yZGVyAAAACWFzc2V0UGFpcgAAAApwcmljZUFzc2V0BwkAAGcAAAACBQAAAANleHAJAABlAAAAAggIBQAAAAFlAAAACXNlbGxPcmRlcgAAAApleHBpcmF0aW9uCAgFAAAAAWUAAAAJc2VsbE9yZGVyAAAACXRpbWVzdGFtcAcJAABnAAAAAgUAAAADZXhwCQAAZQAAAAIICAUAAAABZQAAAAhidXlPcmRlcgAAAApleHBpcmF0aW9uCAgFAAAAAWUAAAAIYnV5T3JkZXIAAAAJdGltZXN0YW1wBwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPQnVyblRyYW5zYWN0aW9uBAAAAAJ0eAUAAAAHJG1hdGNoMAYGF8/Q+A==", sender: "3PMQ27yBjrshdxGmFjTZHY6taN17saQyfM8", senderPublicKey: "2TW1p199hYspTxt3hZc2wm9VGGDE4qFxyY2Th1HoFVww", timestamp: 1550319832173, type: 3, version: 2}, minSponsoredAssetFee: nil, quantity: 2099443248805633, reissuable: false, sponsorBalance: nil}, }
(stdlib) erl_eval.erl:453: :erl_eval.expr/5
(iex) lib/iex/evaluator.ex:257: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:237: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:215: IEx.Evaluator.eval/3
(iex) lib/iex/evaluator.ex:103: IEx.Evaluator.loop/1
(iex) lib/iex/evaluator.ex:27: IEx.Evaluator.init/4
Marked As Solved
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
Look at the output of Poison.decode!(results.body, keys: :atoms). There isn’t a data key. You’re asserting via %{data: items} that the result of Poison.decode! will be a map with an :data key and then data. The JSON does not have any such key.
3
Also Liked
Maxximiliann
Thanks!
Got it working with:
iex(1)> %{balances: items} = Poison.decode!(results.body, keys: :atoms)
1
Popular in Questions
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
I would like to know what is the best IDE for elixir development?
New
Hey,
I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Other popular topics
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New







