I am configuring a json file that contains airflow connections, which are loaded in the backend when I launch my airflow server.
One of the fields, requires me to stringify a dictionary pretty much. I'm having some trouble with the syntax however. I understand that in JSON,
\"
replaces double quotes, but I must be missed something here. Here's an example:
"{\"extra__google_cloud_platform__key_json\":
\"{
\"type\": \"service_account\",
\"project_id\": \"sample-project-id123\",
\"private_key_id\": \"sample_key_id\"
}"
}"
In VS Code, this field is underlined in red, saying things like "Unexpected End of String" and "Colon Expected".
What am I missing here?
CodePudding user response:
If you want just json backlash chars should be removed
{
"extra__google_cloud_platform__key_json": {
"type": "service_account",
"project_id": "sample-project-id123",
"private_key_id": "sample_key_id"
}
}
if you want to convert the json to string, it should be in one line
"{\"extra__google_cloud_platform__key_json\":{\"type\":\"service_account\",\"project_id\":\"sample-project-id123\",\"private_key_id\":\"sample_key_id\"}}";
in your string you have a bug - an extra \ " before {
\"{
\"type\": \"service_account\",
if you remove it and place everything in one line, then it shoud be working too.
CodePudding user response:
The solution for me, was to include everything in one line.