I'm trying to convert JSON data to YAML format but getting an unexpected YAML output
Used online tools to convert JSON to YAML which gives as expected YAML output. But when same JSON used in the below Python code, getting an unexpected different result.
import yaml
job_template = [
{
"job-template": {
"name": "{name}_job",
"description": "job description",
"project-type": "multibranch",
"number-to-keep": 30,
"days-to-keep": 30,
"scm": [
{
"git": {
"url": "{git_url}"
}
}
]
}
}
]
yaml.dump(job_template, open("job_template.yaml", "w"))
Expecting below YAML data:
- job-template:
name: "{name}_job"
description: job description
project-type: multibranch
number-to-keep: 30
days-to-keep: 30
scm:
- git:
url: "{git_url}"
Getting below YAML format:
- job-template:
days-to-keep: 30
description: job description
name: '{name}_job'
number-to-keep: 30
project-type: multibranch
scm:
- git: {url: '{git_url}'}