encoding fails with proplists with string keys
matteoredaelli opened this issue · 1 comments
matteoredaelli commented
It is ok with binary keys
(a@127.0.0.1)42> jsone:encode([{<<"a">>, 1}]).
<<"{\"a\":1}">>
It fails with string keys
(a@127.0.0.1)43> jsone:encode([{"a", 1}]).
** exception error: bad argument
in function jsone_encode:object_key/4
called as jsone_encode:object_key("a",
[{object_value,1,[]}],
<<"{">>,
{encode_opt_v2,false,false,false,
[{scientific,20}],
{iso8601,0},
string,0,0,false,false,
fun jsone:term_to_json_string/1})
in call from jsone:encode/2 (src/jsone.erl, line 386)
sile commented
Yes, jsone
doesn't allow Erlang string keys.
You need to convert Erlang strings to binaries to use as JSON object keys beforehand