Convert ASCII text to JSON String by escaping appropropriate characters.
Note: Since ASCII characters are a subset of Unicode characters and none have u <hex> <hex> <hex> <hex>
format,
this utility doesn't handle characters like Emoji though they are covered in JSON spec.
To quickly convert ASCII text, like contents of Base64 encoded files, to JSON string format. E.g.: X.509 public certificates of PEM format.
Do no trust external websites with any private or confidential or secret data or information.
Excerpt from Introducing JSON:
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
- Quotation mark:
"
- Reverse solidus:
\
- Solidus:
/
- Backspace:
b
- Formfeed:
f
- Linefeed:
n
- Carriage return:
r
- Horizontal tab:
t
- 4 hex digits (unicode characters beyond ASCII):
u hex hex hex hex
String.prototype.replaceAll()
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll- Can I use replaceAll ?: https://caniuse.com/?search=replaceAll