json5 / json5-spec

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

Allow use of backquote to support multiline strings #16

Closed yonatanLehman closed 5 years ago

yonatanLehman commented 5 years ago

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:

jordanbtucker commented 5 years ago

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 commented 5 years ago

How funny, I would have thought the core tennet was to make json easy to use? Why would any potential user prefer es5 compatiblity to ease of use?

I don't mind, my needs are satisfied by my clone, and I suppose I could create a json6 if I wanted, but who would gain from yet another json version? Why do you want to freeze the format forever? Its actually a very minor change, allready coded and tested, with a big jump in ease of use and the json looks much cleaner.

BTW kudos on the code, I managed to change the parser in a couple of hours.

Cheers

בתאריך יום ג׳, 6 באוג׳ 2019, 00:59, מאת Jordan Tucker ‏< notifications@github.com>:

Closed #16 https://github.com/json5/json5-spec/issues/16.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/json5/json5-spec/issues/16?email_source=notifications&email_token=AH2RHBBZ4DB2AJXNPGZZRN3QDCPDFA5CNFSM4IJO7QI2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOS4LV6RQ#event-2534891334, or mute the thread https://github.com/notifications/unsubscribe-auth/AH2RHBDURZVLKII354SWWP3QDCPDFANCNFSM4IJO7QIQ .

jordanbtucker commented 5 years ago

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 commented 5 years ago

Found JSON6 which fits the bill nicely...

בתאריך יום ג׳, 6 באוג׳ 2019, 03:03, מאת Jordan Tucker ‏< notifications@github.com>:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/json5/json5-spec/issues/16?email_source=notifications&email_token=AH2RHBGTFH55URIXM6GERB3QDC5TRA5CNFSM4IJO7QI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3TNNOY#issuecomment-518444731, or mute the thread https://github.com/notifications/unsubscribe-auth/AH2RHBFNX6M6EOUD3FPPPDDQDC5TRANCNFSM4IJO7QIQ .

jianwu commented 4 years ago

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.