elm-community / json-extra

Convenience functions for working with Json.
http://package.elm-lang.org/packages/elm-community/json-extra/latest
MIT License
37 stars 16 forks source link

optionalField does not run decoder on the given field #9

Closed Custodia closed 7 years ago

Custodia commented 7 years ago

optionalField runs decoding on the given object not the given field.

Minimal example of failure: https://ellie-app.com/J93Pt79mbda1/0

This can be fixed by calling field in the given decoder: https://ellie-app.com/J9525YFZvqa1/0

Personally this seems fine to me as it is more flexible but the documentation/name should be clear on what the behaviour of the function is.

Custodia commented 7 years ago

I see there is already a pull request for this at #8

kevgathuku commented 7 years ago

I just spent hours trying to debug the exact same issue. I guess the docs could be clearer on this. I tried your workaround and it worked for me. Thanks 👍