Escaping / to make json embeddable in xml\/html.

This commit is contained in:
Krzysztof Gabis 2015-11-08 16:34:34 +00:00
parent 849f00728b
commit 8324ff92bf
2 changed files with 7 additions and 6 deletions

View File

@ -842,6 +842,7 @@ static int json_serialize_string(const char *string, char *buf) {
switch (c) {
case '\"': APPEND_STRING("\\\""); break;
case '\\': APPEND_STRING("\\\\"); break;
case '/': APPEND_STRING("\\/"); break; /* to make json embeddable in xml\/html */
case '\b': APPEND_STRING("\\b"); break;
case '\f': APPEND_STRING("\\f"); break;
case '\n': APPEND_STRING("\\n"); break;

View File

@ -27,7 +27,7 @@
81,
100
],
"/*": null,
"\/*": null,
"object": {
"nested string": "str",
"nested true": true,
@ -39,11 +39,11 @@
"ipsum"
]
},
"*/": null,
"/**/": "comment",
"//": "comment",
"url": "https://www.example.com/search?q=12345",
"escaped chars": "\" \\ /",
"*\/": null,
"\/**\/": "comment",
"\/\/": "comment",
"url": "https:\/\/www.example.com\/search?q=12345",
"escaped chars": "\" \\ \/",
"empty object": {},
"empty array": []
}