Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Decoding with root object #192

@dunyakirkali

Description

@dunyakirkali

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions