mpx / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
https://kyne.au/~mark/software/lua-cjson.php
MIT License
936 stars 478 forks source link

Why “/” will be escaped #62

Closed imilli closed 6 years ago

imilli commented 6 years ago

exp: local t = {"ban/ana"} local res = cjson.encode(t) print(res)

the result is {"ban\/ana"}

But others json lib will not do this, exp jsoncpp. If i have to do this, is there any way to avoid it?

mpx commented 6 years ago

This package has conservatively escaped characters just in case they cause a problem since it was initially written: https://tools.ietf.org/html/rfc8259#page-9

Does escaping "/" cause a particular problem? Or is it cosmetic? This escaping is not configurable.

In hindsight, there is probably little reason to escape "/".