mirror of
https://github.com/kgabis/parson.git
synced 2025-02-05 17:05:29 +00:00
Escaping / to make json embeddable in xml\/html.
This commit is contained in:
parent
849f00728b
commit
8324ff92bf
1
parson.c
1
parson.c
@ -842,6 +842,7 @@ static int json_serialize_string(const char *string, char *buf) {
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case '\"': APPEND_STRING("\\\""); break;
|
case '\"': APPEND_STRING("\\\""); break;
|
||||||
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 '\b': APPEND_STRING("\\b"); break;
|
||||||
case '\f': APPEND_STRING("\\f"); break;
|
case '\f': APPEND_STRING("\\f"); break;
|
||||||
case '\n': APPEND_STRING("\\n"); break;
|
case '\n': APPEND_STRING("\\n"); break;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
81,
|
81,
|
||||||
100
|
100
|
||||||
],
|
],
|
||||||
"/*": null,
|
"\/*": null,
|
||||||
"object": {
|
"object": {
|
||||||
"nested string": "str",
|
"nested string": "str",
|
||||||
"nested true": true,
|
"nested true": true,
|
||||||
@ -39,11 +39,11 @@
|
|||||||
"ipsum"
|
"ipsum"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"*/": null,
|
"*\/": null,
|
||||||
"/**/": "comment",
|
"\/**\/": "comment",
|
||||||
"//": "comment",
|
"\/\/": "comment",
|
||||||
"url": "https://www.example.com/search?q=12345",
|
"url": "https:\/\/www.example.com\/search?q=12345",
|
||||||
"escaped chars": "\" \\ /",
|
"escaped chars": "\" \\ \/",
|
||||||
"empty object": {},
|
"empty object": {},
|
||||||
"empty array": []
|
"empty array": []
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user