Closed alexchowle closed 5 years ago
I appreciate that solidus can/should be escaped... I'm just wondering if it's possible to prevent it.
Thank you for your question.
Since the escaping logic of /
is hardcoded here, there is no way to prevent it.
Just wanted to chime in that I'm running into the same issue because the generated JSON string gets hashed. I'm using jsone
as it's able to preserve the order of the incoming objects.
The escaping behaviour mentioned in this issue prevents me from using the library and forcing me to fork.
Is there any reason to escape a single forward slash by default?
@the-kenny
Is there any reason to escape a single forward slash by default?
The primary reason is the following (quotes from stack overflow):
JSON doesn't require you to do that, it allows you to do that. It also allows you to use "\u0061" for "A", but it's not required. Allowing
\/
helps when embedding JSON in a<script>
tag, which doesn't allow</
inside strings, like Seb points out.
However, I think it is good to add an option that prevents escaping "/".
Created: #45
Even using native_utf8 option, I can't seem to prevent the encoder from escaping the forward slash.
Example:
Encoding produced for K2 is
\"1\\/2\".