YAML to JSON

Object

foo: bar
yyy: zzz
{
  "foo": "bar",
  "yyy": "zzz"
}

Nested Object

foo:
  bar: baz			# Using 2 spaces

xxx: {yyy: zzz}		# Using object notation, opening curly brace needs to be ON THE SAME LINE

aaa: {				# Opening curly brace needs to be ON THE SAME LINE
bbb:ccc				# SPACES, TAB, and NO SPACE are valid
}					# Closing curly brace can be on same line as bbb:ccc or with extra whitespaces
{
    "foo": {
        "bar": "baz"
    },
    "xxx": {
        "yyy": "zzz"
    },
    "aaa": {
        "bbb": "ccc"
    }
}

List

foo:
  - bar				# With no space or with 2 spaces both valid
  - baz

xxx: [yyy, zzz]

aaa: [
bbb,
ccc
]
{
    "foo": [
        "bar",
        "baz"
    ],
    "xxx": [
        "yyy",
        "zzz"
    ],
    "aaa": [
        "bbb",
        "ccc"
    ]
}

Nested List

foo:
- - bar
  - baz

xxx: [[yyy, zzz]]

aaa: [
    [bbb, ccc]
]
{
    "foo": [
        [
            "bar",
            "baz"
        ]
    ],
    "xxx": [
        [
            "yyy",
            "zzz"
        ]
    ],
    "aaa": [
        [
            "bbb",
            "ccc"
        ]
    ]
}

References:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *