Closed aposto closed 9 years ago
The JSON specification (RFC7159) says:
characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F)
So, it is an error of as expected.
But for convenience, I added allow_ctrl_chars
decoding option from version 1.2.0.
The option allows strings which contain unescaped control characters.
%% Example
% The default value is false
> jsone:decode(<<"{\"_comment_Car_Card\" : \"\tCONTENTSDB\"}">>).
** exception error: bad argument
in function jsone_decode:string/6
called as jsone_decode:string(<<"\tCONTENTSDB\"}">>,<<"\tCONTENTSDB\"}">>,0,
[{object_next,<<"_comment_Car_Card">>,[]}],
<<>>,
{decode_opt_v2,map,false})
in call from jsone:decode/2 (/home/ohta/dev/erlang/jsone/_build/default/lib/jsone/src/jsone.erl, line 208)
% Sets `allow_ctrl_chars` to true
> jsone:decode(<<"{\"_comment_Car_Card\" : \"\tCONTENTSDB\"}">>, [{allow_ctrl_chars, true}]).
#{<<"_comment_Car_Card">> => <<"\tCONTENTSDB">>}
Oh. It's a awesome option. Thank you.
You're welcome.
The expected value is [{<<"_comment_Car_Card">>,<<"\tCONTENTSDB">>}] .