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

JSON section has broken gifDecoder in the print version #267

Open
jon4syth opened this issue Nov 20, 2021 · 1 comment
Open

JSON section has broken gifDecoder in the print version #267

jon4syth opened this issue Nov 20, 2021 · 1 comment

Comments

@jon4syth
Copy link
Contributor

Please fill in the following information:

  • My programming background is: Professional backend developer
  • I want to learn Elm because: I know Elm, just getting back into it after a few years hiatus because want to introduce it at work
  • I was confused by: Why I didn't get the cat gifs as expected when coding along with the example.

Current:

gifDecoder : Decoder String
gifDecoder =
  field "data" (field "image_url" string)

Should be:

gifDecoder : Decoder String
gifDecoder =
  field "data" (field "images" ( field "original" ( field "url" string )))

I didn't do a PR because it would necessitate changing the prose to match the code as well. I guess clicking the "Edit" button gets around this since that code has this fix, so maybe this is not a needed change since beginners are more likely to click the edit button?? If you want to explain the slightly more complex example that matches the current giphy API, I'd be happy to do a PR on the prose, but wanted to check first ;). I think a good solution that is future-proof would be to host a JSON API and the image urls at elm-lang.org as with the HTTP text example or (less future-proof) use a different public API with a singly nested structure.

-Jon

@mandolyte
Copy link

Suggested on Slack by janiczek

Decode.at ["data", "images", "original", "url"] Decode.string

instead of the nested decode fields

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

No branches or pull requests

2 participants