我对灵药真的很陌生,所以请原谅我的无知。我在body
(来自公共 api)中有一个 json 响应,我需要解码两次才能实际获得可以模式匹配的地图。我不明白为什么会发生这种情况以及如何避免它?谢谢。
body = "\"{\\\"access_token\\\":\\\"r5f3w73pjjjoembe4azhp892475wah\\\",\\\"expires_in\\\":5102694,\\\"token_type\\\":\\\"bearer\\\"}\\n\""
result = body |> Jason.decode! |> Jason.decode!
%{"access_token" => access_token} = result
编辑: Postman/Node fetch 中的响应很好,当它来自 Elixir 中的 Tesla 客户端时,它只是像这样逃脱了。