Suppose you have this code:
import dotenv
import json
key = "KEY_TO_SAVE"
value = json.dumps({"test": "me"})
dotenv.set_key(".env", key, value)
What I would expect to see is a .env file that looks like this:
KEY_TO_SAVE="{\"test\": \"me\"}"
However what I actually see is this:
KEY_TO_SAVE="{"test": "me"}"
Because of the lack of escaping quote character, dotenv has effectively changed the value I was trying to set. In this case, the value passed to dotenv is valid JSON, but the value dotenv saves to the file is not valid JSON.
Suppose you have this code:
What I would expect to see is a
.envfile that looks like this:However what I actually see is this:
Because of the lack of escaping quote character, dotenv has effectively changed the value I was trying to set. In this case, the value passed to dotenv is valid JSON, but the value dotenv saves to the file is not valid JSON.