diff --git a/parson.c b/parson.c index 45edaf5..9ee29df 100644 --- a/parson.c +++ b/parson.c @@ -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; diff --git a/tests/test_2_pretty.txt b/tests/test_2_pretty.txt index 829d38d..fe0adfd 100644 --- a/tests/test_2_pretty.txt +++ b/tests/test_2_pretty.txt @@ -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": [] } \ No newline at end of file