How can I decode this?

What an amazingly bizarre API response. How can I extract the list from inside the value (which is a string)?

%{"JSONcallBackStatus" => "[{\"status\":3,\"reason\":\"53\"}]"}

Maybe use Poison decode on the value…

iex> m = %{"JSONcallBackStatus" => "[{\"status\":3,\"reason\":\"53\"}]"}
%{"JSONcallBackStatus" => "[{\"status\":3,\"reason\":\"53\"}]"}
iex> s = m["JSONcallBackStatus"]
iex> Poison.decode! s
[%{"reason" => "53", "status" => 3}]

Use Poison.decode on that string.

1 Like

Ah, of course. I was trying to pattern match to get the first item of the list and then decode it. Thanks!