The most practical solution for this problem I saw was in F#. You can use tripple-quoted strings.
let a = """The diner is called "John's", but you can't let the string end with a double quote"""
https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe... "normal string can contain ' "
r#" raw string can contain " ' "#
r###" if for some reason you need to write "# "###
Kinda like heredocs const hello_world_in_c =
\\#include <stdio.h>
\\
\\int main(int argc, char **argv) {
\\ printf("hello world\n");
\\ return 0;
\\}
;
It neatly sidesteps the whole "cat-and-mouse" issue.Pair this with the fact that it only has the C++ style // comments, it means that every line can be tokenized independently. Not that that particularly matters for programmers, but I know Vim sometimes gets confused about where Python's strings end and it turns the syntax highlighting to garbage.
// the object key here is "weird object key '\""
{%{weird object key '":}%:"see how it works?"}
// ditto
{%""{weird object key '":}""%:"see how it works?"}According to this Stack Exchange answer[0], the backtick is strictly for use in computing. I understand that it represents the grave accent, but that isn't of concern as a string delimiter, because once it is applied to a letter, for example è, it has its own unique representation.
0: https://english.stackexchange.com/questions/249406/are-backt...
The 99% case is a pretty string. The 1% case is a string with escaped delimiters.
E.g., how would you put the following sentence in a string:
You can use both " and ' to delimit a string.
"You can use both \" and ' to delimit a string"
The benefit of JSON is that it's simple, opinionated, and pretty. Putting bells and whistles on it ruins the very ethos of JSON. If you want JSON++, use XML or Jsonnet or whatever.