Closed 3duard0 closed 3 years ago
There is also an error ocurring for Jason.encode!(), but I could not replicate. I think it's for similar reasons.
It seems to be related to how some characters are encoded in strings. The character ç is encoded as <<195, 167>>, instead of the ascii 231(ç in ascii).
The input to Jason.decode!
is defined as iodata
encoding UTF-8 - this means in list of raw integers those integers represent bytes, not unicode codepoints. Jason does not support decoding from chardata
(where raw integers represent codepoints), because that format is not very common for on-the-wire communication.
You can handle chardata
correctly by converting it to iodata
first, simplest of those methods being List.to_string/1
or indeed just the polymorphic to_string/1
. If you need to keep it as a list, there's probably a function in the :unicode
module that could be used for the conversion (though internally Jason operates on binaries only anyway).
Some accentuated characters seems to result in error when decoding json as charlist.
If I remove the offending character(ç) it works