Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upJson.Decode dislikes recursion #664
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Jul 15, 2016
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Jul 15, 2016
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jul 15, 2016
Contributor
This is a known compiler issue. See elm/compiler#873 and the discussion there (explicitly considering JSON decoding in the comments). The current workaround is to make use of lazy from http://package.elm-lang.org/packages/elm-community/json-extra/1.0.0/Json-Decode-Extra#lazy.
|
This is a known compiler issue. See elm/compiler#873 and the discussion there (explicitly considering JSON decoding in the comments). The current workaround is to make use of |
surprisetalk commentedJul 15, 2016
It seems that Json.Decode can't be used recursively.
Consider the following example:
[ { "whatever": 1 , "something": 2 , "things": [ { "whatever": 3 , "something": 4 , "things": [] } , { "whatever": 5 , "something": 6 , "things": [] } ] } ]The web console has the following complaint:
TypeError: undefined is not an object (evaluating 'decoder.tag').The error seems to be occurring in
runHelpinhttps://github.com/elm-lang/core/blob/master/src/Native/Json.js.If you place a
console.log( decoder, value )beforeswitch( decoder.tag )in a compiled file, you'll see that the parent function doesn't pass a decoder object to the recursed child.My current workaround (😅 ) is something like:
I'm willing fix this issue, but I would love some guidance on where to look!
Thank you friends.
ts