sile / jsone

Erlang JSON library
MIT License
291 stars 72 forks source link

escape characters #23

Closed youthy closed 7 years ago

youthy commented 7 years ago

jsone:encode(#{<<"key">> => <<"aaaa/bbbb">>}) => <<"{\"key\":\"aaaa\/bbbb\"}">> jsx/jiffy:encode(#{<<"key">> => <<"aaaa/bbbb">>}) =><<"{\"key\":\"aaaa/bbbb\"}">>

when I use file:write_file, jsone result will be {"key":"aaaa\/bbbb"} others are right

sile commented 7 years ago

In my environment, jsone(v1.4.3) produced the following result:

#
# Erlang Shell
#
> jsone:encode(#{<<"key">> => <<"aaaa/bbbb">>}).
<<"{\"key\":\"aaaa\\/bbbb\"}">>.

> file:write_file("/tmp/temp.json", jsone:encode(#{<<"key">> => <<"aaaa/bbbb">>})).
ok

#
# Bash
#
$ cat /tmp/temp.json
{"key":"aaaa\/bbbb"}

Indeed, it is differ from the jiffy/jsx behaviour. But the above result (i.e., "aaaa\/bbbb") is also a valid JSON string. Therefore, I do not know what you want to point out ... (jsone does not aim to be completely compatible with other JSON libraries.)

If there are any actual problems, it will be helpful if you let me know it.

youthy commented 7 years ago

ehhhh... I thought "xxx:\/xxxx\/xxxx.xx" maybe not a right url. But It can be read as url. I was wrong.~~~

sile commented 7 years ago

Thanks for your reply. I'm glad you have no problem.