Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Poison.Decoder #80

Closed
jaysson opened this issue Feb 3, 2018 · 3 comments
Closed

Implement Poison.Decoder #80

jaysson opened this issue Feb 3, 2018 · 3 comments

Comments

@jaysson
Copy link

jaysson commented Feb 3, 2018

Many times, it is a lot easier to return the record fetched from db in a controller like this:

def show(conn, params)
  address = Repo.get!(Address, params["id"])
  json conn, address
end

However, the address has a Geo.Point field, and poison does not know how to decode it. It would be great if an implementation for Poison.Decoder could be added.

@yordis
Copy link
Contributor

yordis commented Mar 9, 2018

@jaysson did you call

Geo.JSON.encode(address.geo_location) |> Poison.encode!()

or whichever other field and see if it works?

Also, I don't believe this package should be tide to Poison.Decoder, what happened if I don't want to use Poison for my JSON encoding and decoding? That is the reason why Poison is added as optional deps.

Also, you could do something like

defimpl Poison.Encoder, for: Geo.Point do
  def encode(struct, options) do
     # ...
  end
end

@yordis
Copy link
Contributor

yordis commented Mar 10, 2018

Actually looking the code I think that this package depends of Poison instead of being configurable ...

@bryanjos
Copy link
Contributor

This is no longer applicable here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants