Closed CristhianMotoche closed 11 months ago
After some review, I noticed the issue is not related to the starting curly bracket {
but due to the double quote "
after it. It seems dotenv parser allows only escaped quotes after the first character. The following will be parsed correctly:
# .env
JSON={\"a\":[1,2,3],\"b\":\"FOO\ BAR\ BAZ\"}
NOTE that it also needs to escape spaces. I need to review a little bit more the reasons of this initial decision before updating the parser.
After some thought, I think I prefer to keep the behaviour of dotenv since it seems the correct one. If a use wants to set a JSON value in an env variable they can wrap the value in quotes like it is mentioned in the README. Therefore, I'm closing this issue now.
In #169 was reported that JSON content cannot be parsed. The workaround was to warp the content in quotes but that causes some inconveniences since we need to escape inner quotes. Also, due to #178 we cannot do variable substitution. Therefore, we should be able to parse content that starts with curly brackets. For example:
Given:
Should not produce: