Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of backquote to support multiline strings #16

Closed
yonatanLehman opened this issue Aug 5, 2019 · 5 comments
Closed

Allow use of backquote to support multiline strings #16

yonatanLehman opened this issue Aug 5, 2019 · 5 comments
Assignees

Comments

@yonatanLehman
Copy link

Hi
I've implemented a change in parser.js that accepts multiline using backquotes instead of using \ at the end of each line.
{
"val2a" : line 1 line 2,
}
}
Meaning you don't need to add back slashes - the above is equivlient to
{
"val2a" : "
line 1
line 2
"
}
}

I'd like to contribute this to json5, but I am a newbie in open source, so please tell me if you guys will accept it and what I need to do.
I have a few other things I want to do based on this such as:

  • support ${} in some way
  • convert multilines to an array of strings that is standard json for use in other tools
    Regards
    Yonatan Lehman
@jordanbtucker
Copy link
Member

jordanbtucker commented Aug 5, 2019

Thanks for the suggestion. Unfortunately, one of the core tenets of JSON5 is that it must be compatible with ES5. Since this suggestion is not, I'm going to close it.

@yonatanLehman
Copy link
Author

yonatanLehman commented Aug 5, 2019 via email

@jordanbtucker
Copy link
Member

One of the core tenets of JSON5 is to make it easy to use for humans. Adding too many features actually makes it harder for humans to use because it expands the scope of features you need to remember when reading or writing JSON5.

Keeping JSON5 compatible with ES5 protects the project from scope creep. I feel that the set of features provided by JSON5 allows an easy to use (for humans) version of JSON, without making it too difficult for machines to parse it (and for developers to write parsers for it), while also maintaining backward compatibility with JSON.

I had an idea for a version of JSON that evolves with the ES spec, which you can find at https://github.com/jordanbtucker/jsonext, but I haven't been maintaining it. Please feel free to contribute code and ideas there.

@yonatanLehman
Copy link
Author

yonatanLehman commented Aug 6, 2019 via email

@jianwu
Copy link

jianwu commented Sep 27, 2019

I like the philosophy of json5 for most of the points. Really hope it can be pushed as a standard.

But as ES6 has become mainstream version (support by most browsers) and ES5 considered legacy. Make json5 stick with ES5 seems not very reasonable. I really hope it can lose a bit. The ES6 '' string literal is much nicer compared to "\" continuation character. The '' literal makes it much easier to copy/paste the embedded lager to external applications without any modification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants