Questions tagged [elixir-poison]

Poison is a JSON library for Elixir focusing on speed without sacrificing simplicity, completeness, or correctness. Poison uses extensive sub binary matching, a hand-rolled parser using several techniques that are known to benefit HiPE for native compilation, IO list encoding and single-pass decoding. Benchmarks put Poison's performance next to jiffy's. Use this tag in combination with the [elixir] tag.

Poison is a JSON library for Elixir focusing on speed without sacrificing simplicity, completeness, or correctness.

Poison uses extensive sub binary matching, a hand-rolled parser using several techniques that are known to benefit HiPE for native compilation, IO list encoding and single-pass decoding. Benchmarks put Poison's performance next to jiffy's.

Use this tag in combination with the tag.

63 questions
12
votes
1 answer

Duplicate protocol implementations in dependent projects

I have problems with consolidation of protocol implementation in my Elixir project. To be more specific I use Ecto and some simple project called Gold (doesn't matter much atm). The problem is, both of them (Ecto and Gold) use Poison to serialize…
Kelu Thatsall
  • 2,494
  • 1
  • 22
  • 50
11
votes
1 answer

Map with fat arrow vs colon (Poison - json decode)

ab = %{a: 1} ac = %{"a" => 1} What exactly is the difference? And why does Poison.decode! return format #2 (I need #1 to use with Ecto.Changeset.change). Json response is taken from API and looks like [{"a":3}]
Nema Ga
  • 2,450
  • 4
  • 26
  • 49
11
votes
1 answer

Encoding map to JSON using Poison for use with Slack

I'm using Poison to encode a map to JSON that will send it to the Slack API. This is what Poison gives me: "{\"text\":\"changed readme fad996e98e04fd4a861840d92bdcbbcb1e1ec296\"}" When I put that into JSON lint it says it is valid JSON, but Slack…
humdinger
  • 521
  • 1
  • 3
  • 18
7
votes
1 answer

Ordering keys when encoding a map to json with Poison

For reading purposes I would like to have a specific key order into the json file. I know that map's key doesn't have any order and then we should not rely on that, but since Poison is not able to encode proplists I don't see how to do this. iex(1)>…
TheSquad
  • 7,385
  • 8
  • 40
  • 79
4
votes
3 answers

Map JSON values in Elixir

I have parsed the following JSON using Posion.decode! json = %{"color-Black|size:10" => %{"attributes" => %{"color" => "Black","size" => "11"}, "isAvailable" => true, "pricing" => %{"standard" => "$415.00", "sale" => 415}},…
RN92
  • 1,380
  • 1
  • 13
  • 32
3
votes
2 answers

running elixir poison commands in iex

I am a greenhorn in elixir and want to test the Poison functions from iex https://hexdocs.pm/poison/1.3.1/#functions_details iex> Poison.decode("[1,2,3]") When I run this command I am getting the error below. iex(1)> Poison.decode("[1,2,3]") **…
veer7
  • 20,074
  • 9
  • 46
  • 74
3
votes
2 answers

hex dependencies not found for elixir project - poison, absinthe

I am getting unchecked dependency for environment error for ecto.create and ecto.migrate. I have below mix.exs file dependency entry defp deps do [{:phoenix, "~> 1.3"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.3"}, …
Vinayak
  • 55
  • 4
3
votes
1 answer

Overriding Poison Encoders

I'm trying to create a release of my Phoenix application using Distillery and I've overridden the Poison Encoders for DateTime and NaiveDateTime to match the API requirements. When I run mix release, my app compiles but I get an error during .boot…
3
votes
1 answer

Elixir - Capitalized keys in structs

I am trying to write a CLI client in Elixir for an API so that I can login to the API system, fetch the data I need for my calculation and then logout. I have defined a Packet.Login struct that supposed to be my internal data structure that I end up…
Simon
  • 470
  • 1
  • 7
  • 22
3
votes
1 answer

Elixir Decode JSON List into Struct

I am using Elixir to retrieve a json from an external API and store it in a Postgresql database. I am using Poison to decode the json into Elixir Ecto (2.0) schemas. It is working well except for one aspect: an element of the json is a List without…
Will
  • 83
  • 6
2
votes
2 answers

ssl.cipher_suites/0 is undefined or private, use cipher_suites/2,3 instead (ssl 10.4.1) :ssl.cipher_suites()

** (UndefinedFunctionError) function :ssl.cipher_suites/0 is undefined or private, use cipher_suites/2,3 instead (ssl 10.4.1) :ssl.cipher_suites() (hackney 1.15.2) /Users/naveen/NAV/moviematch/deps/hackney/src/hackney_ssl.erl:77:…
navyad
  • 3,752
  • 7
  • 47
  • 88
2
votes
1 answer

Poison.EncodeError at GET /api unable to encode value: {nil, "paths"}

When attempting to render json data I get the following error in my controller. Poison.EncodeError at GET /api unable to encode value: {nil, "paths"} web/controllers/api_controller.ex:1 App.ApiController.action/2 After searching around I attempted…
Emmett Harper
  • 239
  • 4
  • 15
2
votes
1 answer

Poison can't encode JSON (Phoenix)

A continuation of this situation: Can't understand destructuring in JWT auth (Phoenix) I am setting up an API authentication using JWT with Guardian and Comeonin. This action seems to work, in that calling a user from iex and passing it into…
Mark Karavan
  • 2,654
  • 1
  • 18
  • 38
2
votes
1 answer

Encode a tuple of strings with poison

I'm trying to encode this tuple of strings with poison: {"product existed but could not add categories to product", "Shop existed but could not add product to shop"} Getting this error: 19:10:21.593 [error] #PID<0.339.0> running Api.Router…
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
2
votes
1 answer

Poison unable to encode error message

I am using phoenix as a JSON API. One of my models is as below which works well unless the unique_constraint check fails. When that happens I get the following error: (Poison.EncodeError) unable to encode value: {"Email address is already…
Razzildinho
  • 2,564
  • 1
  • 19
  • 32
1
2 3 4 5