Passing the example parameter in the question is relatively straightforward. The only rule applying is that the quotes ("
) have to be escaped using backslashes (\"
). For a more complicated example with more rules applying see Pycharm deletes quotation marks in paramenter field.
Run/Debug Configuration: Python
Configuration tab
When specifying the script parameters, follow these rules:
(...)
- If script parameter includes double quotes, escape the double quotes with backslashes,
So the example JSON string:
{"beam":5,"max_len_a":1.2,"max_len_b":10}
should be written as:
{\"beam\":5,\"max_len_a\":1.2,\"max_len_b\":10}
You can then easily convert the parameter to a JSON object using the script
import json
import sys
your_string = sys.argv[1]
z = json.loads(your_string)
The following screenshot shows the run configurations:
