ar0lak

ar0lak

Problems encoding a nested map with poison

Can seem to encode this this json with Poison v4, using phoenix v1.4.1, getting error related to erlang.byte_size(…)

Any help would be appreciated.

** (Mix) Could not start application tradebot: Tradebot.Application.start(:normal, []) returned an error: shutdown: failed to start child: FTX.Client
    ** (EXIT) exited in: WebSockex.call(#PID<0.344.0>, {:text, {:ok, "{\"args\":{\"key\":\"fooooobaaarrrrbazzzzzzzz\",\"sign\":\"d10b5a67a1a941ae9463a60b285ae845cdeac1b11edc7da9977bef0228b96de9\",\"time\":\"1572290285343518000\"},\"op\":[108,111,103,105,110]}"}})
        ** (EXIT) an exception was raised:
            ** (ArgumentError) argument error
                :erlang.byte_size({:ok, "{\"args\":{\"key\":\"fooooobaaarrrrbazzzzzzz\",\"sign\":\"d10b5a67a1a941ae9463a60b285ae845cdeac1b11edc7da9977bef0228b96de9\",\"time\":\"1572290285343518000\"},\"op\":[108,111,103,105,110]}"})
                (websockex) lib/websockex/frame.ex:374: WebSockex.Frame.get_payload_length_bin/1
                (websockex) lib/websockex/frame.ex:324: WebSockex.Frame.encode_frame/1
                (websockex) lib/websockex.ex:897: WebSockex.sync_send/5
                (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Marked As Solved

idi527

idi527

:wave:

Seems like you are encoding it just fine, but the result is a tagged tuple, {:ok, json}. You can either extract the json value from the tuple or use a “bang” version of the encoding command which returns the value directly.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
belgoros
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
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement