Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backslash character not rendered as \\ when escapeControlCharacters:true #131

Closed
josdejong opened this issue Aug 26, 2022 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@josdejong
Copy link
Owner

Example document:

{
  "backslash": "\\",
  "return": "1\n2",
  "tab": "a\tb"
}

When escapeControlCharacters:true, the backslash should be rendered as \\ in tree mode, but it is rendered as \

@josdejong josdejong added the bug Something isn't working label Aug 26, 2022
@josdejong
Copy link
Owner Author

Also, an escaped slash is not rendered correctly:

{ 
  "escapedSlash": "\/\/"
} 

This is rendered as // instead of \/\/.

@josdejong
Copy link
Owner Author

The issue with escaped backslashes \\ (reverse solidus) is solved.

The issue with forward slashes \/ (solidus) not. The difficulty is that escaping of this character is optional, and that in JavaScript there is no difference between the two: '\/' === '/'. As soon as you parse the JSON, the \/ character is turned into / and this information is lost. This can't be fixed with the built-in JSON parser. I found the following discussion and background information helpful in this regard: https://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant