Bug 17587 – JSONOptions: No forward slash encoding

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-03T14:53:10Z
Last change time
2018-01-05T13:30:04Z
Assigned to
No Owner
Creator
Andre

Comments

Comment #0 by andre — 2017-07-03T14:53:10Z
In most cases I use std.json I do not want the \/ encoding. For example I build a AWS SDK. The structures are serialized to JSON which is passed to the AWS client for execution. I do a very naive string replacement \/ with /. I have similiar cases where I do this string replacement and wonder whether \/ encoding can be deactivated by adding an additional JSONOptions flag
Comment #1 by dlang-bugzilla — 2017-07-03T15:30:17Z
Is not escaping / desired for purely a size optimization, or is the escaping actually breaking something?
Comment #2 by andre — 2017-07-04T14:56:37Z
In my AWS SDK I had the issue that \/ was not accepted while passing the JSON as console argument to the AWS console client. In the meantime I save the JSON as file and pass the file name to the AWS console client. Here the \/ is accepted quite fine. I tried to reactive the old behavior but wasn't able, because passing JSON as console argument is quite another beast... My other use cases is purely optical. In an http server I generate JSON documents on the fly which are outputed to the browser. One example is an ODATA2 server framework. Something similiar to this one http://services.odata.org/V2/Northwind/Northwind.svc/Customers?$FORMAT=JSON With the right Chrome plugin, the links are clickable but I have to replace \/ in http://...
Comment #3 by andre — 2017-07-05T21:00:17Z
I just noticed another scenario in which I face the issue. I have a d application which adapt a dub.json configuration file. It adds some some sub packages which are created via my application. I read the file as text, parses the text into JSON (std.json) adapt the JSON and store it again as file. If the file contains a homepage attribute, it will be rewritten as http:\/\/...\/... This rewriting is not intended.
Comment #4 by ag0aep6g — 2017-07-05T21:40:57Z
Pull request to move this forward to some resolution: https://github.com/dlang/phobos/pull/5552
Comment #5 by destructionator — 2017-07-05T22:44:32Z
> In my AWS SDK I had the issue that \/ was not accepted while passing the JSON as console argument to the AWS console client. Sounds like you should be shell encoding the data first anyway!
Comment #6 by github-bugzilla — 2017-07-21T14:02:27Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/0503b9b4a55512335ce038a34aa57a137b76753d add JSONOptions.doNotEscapeSlashes Fixes issue 17587 (enhancement request). https://github.com/dlang/phobos/commit/987ebc54baffe1d8cf41a560ab7a746721e1c7de Merge pull request #5552 from aG0aep6G/17587 don't escape slash in toJSON (issue 17587)
Comment #7 by github-bugzilla — 2017-08-16T13:23:45Z
Comment #8 by github-bugzilla — 2018-01-05T13:30:04Z