-
Notifications
You must be signed in to change notification settings - Fork 415
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
JSON Values are improperly stored #285
Comments
Hi @mslinn . Thanks for creating a new issue. Let's take the example
Now let's parse this file using
If you run this Python file, you will see that the output is:
In other words, it parsed the Now, you may still have a preference for using single quotes instead of double quotes. May I ask, how are you creating the |
The motivation for this issue is for |
That seems like a good goal, to achieve comptability with different Older versions of
This is because older versions of Using If you can't find any examples of parsers that break with double quotes, I think it would be preferable to keep the existing behaviour of python-dotenv, in order to preserve compatibility with older versions of python-dotenv. |
I am writing docs and blogging, using Jekyll plugins. I would have to write a special filter just so that JSON contents would display properly when including portions of .env files if I used |
Just to clarify, you are using the CLI ( If all you want is show portions of .env files, then you should be able to use single quotes. The dotenv CLI is quite limited at the moment. Supporting both types of quotes might be good since they have different semantics in python-dotenv (e.g. variables are not expanded in single-quoted values). |
Yes, bash expansion is also inhibited by single quotes as well. |
I'm not very familiar with Jekyll. Does it parse You could use the environment variables in
That way, Jekyll would have access to all the settings in |
Jekyll does not know about .env files. I wrote Jekyll plugins to help me document code. Some of those plugins read and filter data from files. I would like to be able to include portions of .env files in the docs. If the files do not store proper JSON my task becomes much harder. |
Unless I missed something you didn't answer my question. Do you really need to use the CLI? Otherwise, just write the single-quoted JSON value in the file and python-dotenv will be able to read it the way you want. Regardless of that problem, I'll consider switching to single-quotes in the implementation of |
This should be fixed by #330 when it's merged. In case you'd like to test it, I'd be happy to know what you think about it. |
python-dotenv
does not store valid JSON. The JSON standard requires double quotes and will not accept single quotes, nor will the parser.JSON values are escaped to death by
python-dotenv
because double quotes are used to delimit values. For example, instead of storing JSON values nicely, like this:They are stored as:
... which is not JSON. Yes, it could be transformed into JSON.
python-dotenv
reads values surrounded by single quotes without any problem. Is there a technical reason why values are not stored by default surrounded by single quotes?The text was updated successfully, but these errors were encountered: