d3x0r / JSON6

JSON for Humans (ES6)
Other
236 stars 14 forks source link

Single quote and newlines #14

Closed micheleriva closed 3 years ago

micheleriva commented 5 years ago

Hi! Sorry for that kind of question, I feel a bit stupid asking but... why should I keep a newline while using a single quote? This feature already exist in ES6 using template literals (which correctly works following your documentation), but why should I change the way I use single quotes? Ok that last sentence is a little bit provocative 😄, but what is the real advantage of that kind of approach?

{...
 thisAlso: 'is a
multi-line string; but keeps newline',
...}

Btw I love that JSON6 proposal! thanks!

d3x0r commented 5 years ago

It's not really that I'm trying to encourage changing what you do or what is generated, merely explain behavior before someone says they were surprised... It fell out from a little laziness, and not wanting to test 'is this string type 1, 2 or 3(template)' when I added 'just add newline to the string'; it's slightly less work for the string gatherer...

Conversely I didn't really see a reason to NOT collect newlines, and throw an exception; being more generous on what is treated as valid.