mpx / lua-cjson

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

Why “/” will be escaped #62

Closed imilli closed 5 years ago

imilli commented 5 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 5 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 "/".