我的JSON如下所示
{ "resp":
[ [1, "things"]
, [2, "more things"]
, [3, "even more things"]
]
}
Run Code Online (Sandbox Code Playgroud)
问题是我无法将JSON元组解析为Elm元组:
decodeThings : Decoder (List (Int, String))
decodeThings = field "resp" <| list <| map2 (,) int string
Run Code Online (Sandbox Code Playgroud)
它编译,但运行时,它会抛出
BadPayload "Expecting an Int at _.resp[2] but instead got [3, \"even more things\"]
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它只读取[3, "even more things"]一件事而不是JSON格式的元组.
我怎样才能将我的JSON解析成List (Int, String)?