I am trying below code
data = Poison.decode!(payload)
|> ProperCase.to_snake_case
Logger.info("data is #{data}")
Where the payload is from Messging Queue
{
"name":"Joe",
"id": "13",
"version": 0
}
With this I am getting an error
[error] Could not process PerfectFlight: %Protocol.UndefinedError{description: "", protocol: String.Chars, value: %{"id" => "13", "name" => "Joe", "version" => 0}}
However, If I change my input json to
"{
\"name\":\"Joe\",
\"id\": \"13\",
\"version\": 0
}"
The Poison.decode()
works pefectly fine. Now the issue is that I don't want to change my input JSON
because of many reasons. What am I missing?
Edit : The code was failing not at the decode but on the next line Logger.info("data is #{data}")
. Since the output of decode
function is not a String
I should rather use IO.inspect as below. Accepting Adams answer for his confidence in decode function.
data = Poison.decode!(payload)
|> ProperCase.to_snake_case
IO.inspect(data)