poison icon indicating copy to clipboard operation
poison copied to clipboard

Decoding with root object

Open dunyakirkali opened this issue 5 years ago • 0 comments

I'm trying to decode a json object which has a root object.

So basically my json looks like this:

"Id": {
  "id": 1561
}

And when I parse it with Poison I would like to get

%Id{id: 1561} == Poison.decode!("\"Id\":{\"id\":1561}", %Id{})

where Id is:

defmodule Id do
  @derive [Poison.Encoder]
  defstruct [:id]
end

I couldn't find a way to deal with root object. Is that possible?

dunyakirkali avatar Sep 20 '19 08:09 dunyakirkali