Is it possible to write a json file using the contents
keyword? I first tried the following:
"samples-json": {
"basename": "samples_json.json",
"class": "File",
"contents": {"R": "R1", "sex": "Unknown"}
},
But I received this error:
the `contents` field is not valid because value is a CommentedMap, expected null or string
I then tried it as a string, while escaping the internal quotes in the json:
"samples-json": {
"basename": "samples_json.json",
"class": "File",
"contents": "{\"R\": \"R1\", \"sex\": \"Unknown\"}"
},
But then the quotes are also escaped inside of the resulting json file, and the contents of the file are interpreted as a single string by the tool (which opens it using json.load(open("samples_json.json"))
.
What would be the proper way to escape the double quotes in the inputs file, while leaving them unescaped in the dynamically-generated one?