Decode JSON Nested Objects

Ahh ok yeah I was using as: but I just wasn’t sure what the whole syntax would look like.

This is what I have now:

Poison.decode(body, as: %{
          "_embedded" => %{
            "currently_collection" => [%CurrentlyReprModule.CurrentlyBlock{}]
            },
          "_links" => %CurrentlyReprModule.Links{},
          "page" => [%CurrentlyReprModule.Page{}]
        })

But then I get this error:

expected a map, got: {"number", 0}

This must be coming from the "page" part of the JSON response but I don’t know why it’s happening. Decoding this should be straightforward. Here is the Page struct:

defmodule Page do
    @derive [Poison.Encoder]
    defstruct [:size, :totalPages, :totalElements, :number]
end

Thanks!