json5 / json5-spec

The JSON5 Data Interchange Format
https://spec.json5.org
MIT License
50 stars 10 forks source link

Allow backquoted string (a.k.a., Template’s strings) #34

Closed yairlenga closed 3 years ago

yairlenga commented 3 years ago

Would like to suggest adding the back quote string (subset of ES6 template string) operator as an alternative to the single quote/double quote already supported.

see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

The main advantage is that template string will allow embedding multi-line string, without having to escape the new lines. This will allow embedding other text directly, instead of the tedious effort to escape the new lines at the end of every line.

to emphasize: I am not suggesting that to add support for interpolation, or any of the other features supported by template string in ESMA script. The syntax should match the template string as by link above.

jordanbtucker commented 3 years ago

Thank you for your suggestion. JSON5 adheres to the syntax of ECMAScript 5. This is to ensure long-term compatibility and also to avoid scope creep and bloat. If you would like to use template syntax with JSON-like formats, you can look into JSONext.