evancz / guide.elm-lang.org

My book introducing you to Elm!
https://guide.elm-lang.org/
Other
321 stars 187 forks source link

JSON section has broken gifDecoder in the print version #267

Open jon4syth opened 2 years ago

jon4syth commented 2 years ago

Please fill in the following information:

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 commented 2 years ago

Suggested on Slack by janiczek

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

instead of the nested decode fields