Poison return invalid when I parse a valid json string that has 0
prefix.
For example,
Poison.Parser.parse("{\"mynumber\":09315}")
returns {:error, {:invalid, "9", 13}}
, but if I remove 0 prefix Poison.Parser.parse("{\"mynumber\":9315}")
returns {:ok, %{"mynumber" => 9315}}
.
I would like to know why "{\"mynumber\":09315}"
is not valid. Is there any workaround?
Why is JSON invalid if an integer begins with a leading zero? explains the reason why
"{\"mynumber\":09315}"
is invalid.for workaround I just replace wiht
String.replace("{\"mynumber\":09315}", ~r/\"mynumber\"\:0*/, "\"mynumber\":")
before parsing it