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
0
votes
1 answer

Getting error parsing List in map with Poison in elixir

I am trying to parse an api query but I get an error in the following code: apiUrl = "https://api.trivia.willfry.co.uk/questions?limit=1" HTTPoison.start() {:ok, req} = HTTPoison.get(apiUrl) # Parses the request. json =…
Rik Smits
  • 31
  • 7
0
votes
1 answer

HTTPoison: request getting closed

https://yts.lt/api/v2/list_movies.json?query_term=tt11296058 Above URL is always available and gives the expected output (JOSN) while accessing from browser But sometimes (randomly) while access same URL using httposion, following error…
navyad
  • 3,752
  • 7
  • 47
  • 88
0
votes
2 answers

How to define a module in Phoenix that uses the Poison Library

I am new to Elixir and Phoenix so this problem is probably fairly trivial. My Phoenix application is an API client and I am trying to create a struct to model the data I will receive from the REST endpoint. I basically followed the small example on…
Walker Sorlie
  • 53
  • 1
  • 1
  • 7
0
votes
2 answers

Elixir: extract element in a large structured data

I made a get request with HTTPoison, but now I'm trying to parse the JSON file. For that I'm using Poison library. But I'm having some problems to get an element from the JSON object. Here my code : def parse_json do IO.puts("\nLet's parse JSON…
0
votes
0 answers

How to escape a single backslash in Elixir when encoding to JSON?

I have this body for a request, which in Elixir is represented like this: body = %{ password: "my\Password" } I use Poison.encode! to convert it to JSON and what it is being sent is this: %HTTPoison.Request{ body:…
TheoK
  • 3,601
  • 5
  • 27
  • 37
0
votes
1 answer

Elixir - convert http response json to ecto.schema object

I am a newbie to elixir. I have a Ecto Schema defmodule MyScoreSchema do use Ecto.Schema import Ecto.Changeset schema "historical_extra_fuels" do field :average, :float field :count, :float field :percent, :float field…
veer7
  • 20,074
  • 9
  • 46
  • 74
0
votes
1 answer

Poison cannot parrse a json string that has 0 prefix

Poison return invalid when I parse a valid json string that has 0 prefix. For example, Poison.Parser.parse("{\"mynumber\":09315}") returns {:error, {:invalid, "9", 13}}, but if I remove 0 prefix Poison.Parser.parse("{\"mynumber\":9315}") returns…
Khaino
  • 3,774
  • 1
  • 27
  • 36
0
votes
0 answers

Poison.decode/2 is undefined in production

My function in elixir 1.9 decodes json response from an external api and looks like this: def decode({ok, body, "application/json"}) when is_binary(body) do body |> Poison.decode(keys: :atoms) |> case do {:ok, parsed} -> {ok,…
Masinde Muliro
  • 1,175
  • 3
  • 24
  • 38
0
votes
0 answers

Second HTTPoison.get request returns 404

I'm testing out making multiple requests to various URLs doing a some web scraping - and after the first request, the second often fails. I can't figure out why: I make two simple requests to sites, and what's happening is the second request is…
Brian
  • 857
  • 2
  • 12
  • 25
0
votes
2 answers

Get data from a JSON Array

I have a JSON array: response = [ %{ "created_at" => 1542757526, "email" => "bcs@yahoo.com", "first_name" => "rana", "id" => "YW1pcnBheWFyeUB5YWhvby5jb20=", "last_clicked" => nil, "last_emailed" => nil, "last_name" =>…
Rana. Amir
  • 187
  • 3
  • 15
0
votes
1 answer

elixir poison not able to decode JSON

I am trying below code data = Poison.decode!(payload) |> ProperCase.to_snake_case Logger.info("data is #{data}") Where the payload is from Messging Queue { "name":"Joe", "id": "13", "version": 0 } With this I am…
veer7
  • 20,074
  • 9
  • 46
  • 74
0
votes
3 answers

Dockerized Phoenix/Elixir App Rejects All HTTP/socket requests

I'm trying to follow along with this tutorial to get my (functioning on localhost) elixir/phoenix app running in a docker container and I'm running into…
Peter Weyand
  • 2,159
  • 9
  • 40
  • 72
0
votes
1 answer

Duplicated modules: 'Elixir.Poison.Encoder.Map' specified in poison `mix release`

I am working in an umbrella application that works with Poison to encode and decode Json. In order to encode my ecto models I write the following implementation: def defimpl Poison.Encoder, for: Any do def encode(%{__struct__: App.Models.Task} =…
0
votes
2 answers

Poison : unable to encode value

I am not able to encode values which I am getting from Ecto query result Poison encode method Controller code: def companies(conn, params) do companies = Repo.all( from( c in Company, select: {c.name, c.uid}, …
Jagdish
  • 752
  • 8
  • 23
0
votes
1 answer

Poison seems to automatically convert a JSON array of objects to a map. What can I do to prevent that?

In my app I accept a JSON object at one of the API endpoints: pipeline :api do plug :accepts, ["json"] end Within this JSON object, there is an array of objects, e.g. the structure might be like this: { "a": "...", "b": [{"c": "...", "d":…
xji
  • 7,341
  • 4
  • 40
  • 61