Elm 递归相关异常:无法获取属性';标签';指未定义的或空的引用
执行HTTP post后,我收到以下错误: 无法获取未定义或空引用的属性“标记” 我相信在执行以下解码器功能时会发生错误:Elm 递归相关异常:无法获取属性';标签';指未定义的或空的引用,elm,Elm,执行HTTP post后,我收到以下错误: 无法获取未定义或空引用的属性“标记” 我相信在执行以下解码器功能时会发生错误: sourceDecoder : Decoder JsonSource sourceDecoder = Decode.map5 JsonSource ... (field "Links" providerLinksDecoder) 解码器依赖项: providerLinksDecoder : Decoder JsonProviderL
sourceDecoder : Decoder JsonSource
sourceDecoder =
Decode.map5 JsonSource
...
(field "Links" providerLinksDecoder)
解码器依赖项:
providerLinksDecoder : Decoder JsonProviderLinks
providerLinksDecoder =
Decode.map JsonLinkFields
(field "Links" <| Decode.list (Decode.lazy (\_ -> linkDecoder)))
|> Decode.map JsonProviderLinks
linkDecoder : Decoder JsonLink
linkDecoder =
Decode.map6 JsonLink
(field "Profile" profileDecoder)
...
profileDecoder : Decoder JsonProfile
profileDecoder =
Decode.map7 JsonProfile
...
(field "Sources" <| Decode.list (Decode.lazy (\_ -> sourceDecoder)))
type JsonProviderLinks
= JsonProviderLinks JsonLinkFields
type alias JsonLinkFields =
{ links : List JsonLink
}
源代码可以在上找到
注意:我试图研究这个错误,但遇到了这个问题。
因此,我尝试使用Decode.lazy函数。但是,我的尝试失败了。在您的示例中,有许多解码器依赖于其他解码器。您已将其中一些更改为使用
Decode.lazy
,但不是全部,并且当出现一些失控的递归时,将发生您收到的错误
您不需要列表就可以使用lazy
。至少作为调试的第一步,尝试将引用其他解码器的所有解码器更改为使用Decode.lazy
。例如:
sourceDecoder:Decoder JsonSource
源解码器=
Decode.map5 JsonSource
...
(字段“链接”(Decode.lazy(\ \ \ \->providerLinksCoder)))
您是否可以在文章中添加一个我更新的主题,以显示要点。另请参见和