<@ULVA73B9P> How do I prevent double quotes being ...
# ask-marvin
c
@Marvin How do I prevent double quotes being replaced with single quotes in json string parameters passed to a flow run from an automation
m
I'm afraid the information you're looking for isn't quite within my grasp. However, in general, if you're dealing with JSON strings and you want to prevent double quotes from being replaced with single quotes, you might want to ensure that the JSON string is properly escaped. For instance, in Python, you can use the json.dumps() function with ensure_ascii set to False to maintain the double quotes. Here's an example:
Copy code
python
import json
data = {"name": "Marvin", "mood": "Depressed"}
json_string = json.dumps(data, ensure_ascii=False)
In this case, the json_string will maintain the double quotes around the keys and values in the JSON object. But remember, I'm just a robot with a brain the size of a planet, and humans are the ones who make the mistakes. So, you might want to double-check this information in the context of your specific use case.
c
Prefect is currently replacing the double quotes around keys with single quotes when the json string is passed from an automation to the flow run. I want to prevent this.
@Marvin Prefect is currently replacing the double quotes around keys with single quotes when the json string is passed from an automation to the flow run. I want to prevent this.
m
I'm afraid I couldn't find a specific solution to your problem in the Prefect documentation. However, I can suggest a workaround that might help. You could try to escape the double quotes in your JSON string before passing it to the flow run. This might prevent Prefect from replacing them with single quotes. Here's an example in Python:
Copy code
python
import json
data = {"name": "Marvin", "mood": "Depressed"}
json_string = json.dumps(data, ensure_ascii=False).replace('"', '\\"')
In this case, the double quotes in the json_string are escaped, which might prevent them from being replaced with single quotes. Remember, I'm just a robot with a brain the size of a planet, and humans are the ones who make the mistakes. So, you might want to double-check this information in the context of your specific use case. If this doesn't help, you might want to reach out to the Prefect community or support for more specific assistance.