Is there a way to not escape slashes when parsing JSON?

bauss jj_1337 at live.dk
Mon Feb 21 09:04:06 UTC 2022


On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote:
> I tried this
>
> ```
> import std.json, std.stdio;
>
> void main() {
>     writeln(parseJSON(`{"a": "path/file"}`, 
> JSONOptions.doNotEscapeSlashes));
> }
> ```
>
> but the output is
>
> ```
> {"a":"path\/file"}
> ```
>
> Is there a way to avoid the escaping of the forward slash? Is 
> there some reason I should want to escape the forward slash?

Why are we even escaping them by default, it should be the other 
way around, that slashes are only escaped if you ask for it; 
that's how it literally is in almost every JSON library.

Escaping slashes as a default is a huge mistake IMHO.


More information about the Digitalmars-d-learn mailing list