Closed gmlewis closed 2 months ago
The json package will add \ before escapes, including ", \, and /, when stringifying a json object. https://github.com/moonbitlang/core/blob/34096f4e37269777274b3ed6a2eed499890ae030/json/json.mbt#L146 There are some discussion on stack overflow. I think it’s just a matter of choosing.
According to the ECMA specification, the forward slash can be escaped. But some implementations choose not to escape it or provide an option.
https://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped
Maybe we can align with JavaScript's behavior.
following other language's conventions, we provide a flag so you can set it, e.g,
xx.stringify(escape_flash=false)
following other language's conventions, we provide a flag so you can set it, e.g,
xx.stringify(escape_flash=false)
Excellent... Thank you! Additionally, you might want to add some flags to support pretty-printing with indentation.
In JavaScript, if I write this:
However, in MoonBit, if I write this:
I get this: