Tests added.
case '"':
case '\\':
case '/':
+ if((flags & JSON_C_TO_STRING_NOSLASHESCAPE) && c == '/')
+ {
+ pos++;
+ break;
+ }
+
if(pos - start_offset > 0)
printbuf_memappend(pb, str + start_offset, pos - start_offset);
else if(c == '\f') printbuf_memappend(pb, "\\f", 2);
else if(c == '"') printbuf_memappend(pb, "\\\"", 2);
else if(c == '\\') printbuf_memappend(pb, "\\\\", 2);
- else if(c == '/' &&
- (flags & JSON_C_TO_STRING_NOSLASHESCAPE))
- {
- pos++;
- break;
- }
else if(c == '/') printbuf_memappend(pb, "\\/", 2);
start_offset = ++pos;
printf("my_string.to_string(NOSLASHESCAPE)=%s\n", json_object_to_json_string_ext(my_string, JSON_C_TO_STRING_NOSLASHESCAPE));
json_object_put(my_string);
+ my_string = json_object_new_string("/foo/bar/baz");
+ printf("my_string=%s\n", json_object_get_string(my_string));
+ printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
+ printf("my_string.to_string(NOSLASHESCAPE)=%s\n", json_object_to_json_string_ext(my_string, JSON_C_TO_STRING_NOSLASHESCAPE));
+ json_object_put(my_string);
+
my_string = json_object_new_string("foo");
printf("my_string=%s\n", json_object_get_string(my_string));
printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
my_string=/
my_string.to_string()="\/"
my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
my_string=foo
my_string.to_string()="foo"
my_int=9
my_string=/
my_string.to_string()="\/"
my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
my_string=foo
my_string.to_string()="foo"
my_int=9
my_string=/
my_string.to_string()="\/"
my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
my_string=foo
my_string.to_string()="foo"
my_int=9
my_string=/
my_string.to_string()="\/"
my_string.to_string(NOSLASHESCAPE)="/"
+my_string=/foo/bar/baz
+my_string.to_string()="\/foo\/bar\/baz"
+my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz"
my_string=foo
my_string.to_string()="foo"
my_int=9