www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15510] New: json shouldn't escape forward slash by default

https://issues.dlang.org/show_bug.cgi?id=15510

          Issue ID: 15510
           Summary: json shouldn't escape forward slash by default
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

void main(){
  import std.json;
  JSONValue v = [ "file": "a/b"];
  auto v2=v.toString;
  assert(v2==`{"file":"a\/b"}`, v2);
}

It would be nice to have an option (which should be default IMO) to not escape
forward slashes.

context:
http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped
https://github.com/esnme/ultrajson/issues/110
QUOTE: The JSON spec says that forward slashes may be escaped or not escaped.
Unless there is a compelling reason to escape them it would be preferable to
follow the behavior of Python's json module and not escape them.

--
Jan 03 2016