0
我试图在嵌套的JSON响应中查找URL并映射它们。我的功能到目前为止是这样的:Elixir:通过嵌套JSON中的值前缀查找
def list(env, id) do
Service.get_document(env, id)
|> Poison.decode!
|> Enum.find(fn {_key, val} -> String.starts_with?(val, 'https') end)
end
的JSON看起来大致是这样的:
"stacks": [
{
"boxes": [
{
"content": "https://ddd.cloudfront.net/photos/uploaded_images/000/001/610/original/1449447147677.jpg?1505956120",
"box": "photo"
}
]
}
],
"logo": "https://ddd.cloudfront.net/users/cmyk_banners/000/000/002/original/banner_CMYK.jpg?1397201875"
所以URL可以有任意键,并且在任何级别。
与该代码我得到这个错误:
no function clause matching in String.starts_with?/2
任何人有一个更好的方式,JSON响应找?
这是_brilliant_,对于大量的帮助来说非常重要。再次。 –