Rectangle 27 0

YAML is a super-set of JSON. So, a valid JSON is also a valid YAML (but valid YAML isn't necessarily valid JSON).

>>> import yaml
>>> import json

>>> orig_yaml_txt = "---\nasset_data:\n- {assetDefaultScenePath: 'C:\\\\data\\\\my_newfile.ma',\n  assetName: new_asset}\n- {assetDefaultScenePath: 'C:\\\\assetA.ma',\n  assetName: assetA.ma}\naudio_dir: ''\nbg_dir: ''\ndestination: ''\nepisode: '00'\nprod: test\n"
>>> dict_1 = yaml.load(orig_yaml_txt)
>>> intermediate_json_txt = json.dumps(dict_1)
>>> dict_2 = yaml.load(intermediate_json_txt)
>>> dict_1 == dict_2
True

In the above snippet, I take your YAML-serialized text, load it into a python dictionary, then dump that to a json-serialized text, and then load it into a python dictionary using YAML to parse.

In your question, you state that the original YAML is generated from Ruby. Perhaps, instead of dumping YAML, you could dump JSON from Ruby, or add another step in the pipeline that converts the YAML to JSON before being fed to MEL.

That was my first attempt but passing JSON has different complications. Since the data is parsed via command line I would need escape sequence to work with double quotes. Thats why I need a serialization which uses single quotes. I hope that makes sense.

what do you mean passed via command line, as in a piped? would you mind updating your question with how your data is being passed through the command line. Also, instead of "passing the data through the command line" maybe you could write the json/yaml to a file and read from the file in the next stage of the program

Edited the question. I know I can pass a file and that's what I did :) but its not ideal.

python - Yaml dump without new line - Stack Overflow

python yaml
Rectangle 27 0

Thanks @MathieuMarques for suggesting to look @ dump options and link provided, YAML documentation was not good enough to find it out.

width
dump
yaml.dump(data, width=1000)

python - How to prevent YAML to dump long line without new line - Stac...

python yaml line-breaks dump long-lines