Fix for #84
Adds support in the parser for treating JSON values specially. If the entire value is enclosed in curly braces or brackets, treat the value as a JSON string. Treat quotes and spaces inside the JSON value as literals.
Hi @ansel1, thank you for submitting a PR.
I don't think the parser should care about the format of the value. It doesn't matter if the value is JSON, TOML, valid to the spec, or invalid. We just want to be able to parse a value that contains double quotes, like a typical JSON, without escaping.
I added a comment on the issue. I'm happy to hear your thoughts.
I tend to agree, but I'm not sure how else other libraries would have implemented this. The rules inside probable JSON structures are just so different than the normal rules: spaces, double quotes and single quotes should be treated as literals, but substitution should still work (debatable I guess), and therefore slash-escape still needs to work...it's like a universe with different rules of physics.
Arguably, even the substitution and escape semantics should be disabled, and the entire value should be treated like a strong quote, since dotenv's escape character collides with JSON's.
That's why I put in the logic to only activate this mode when the entire value looks like a JSON object or array: to limit the blast radius of unintended side effects.