Data structure terminology

Andreas Baekdahl

Did you know there is now such thing as a YAML list or a JSON dictionary?

Let's get the terminology straight for basic data structures across four of the code languages we could encounter in the DevNet certification program.

Python

JSON

YAML

HCL

A Python dictionary contains multiple entries
{
 'key_a': 'value_a',
 'key_b': 'value_b'
}
A JSON object contains multiple properties
{
 "name_a": "value_a",
 "name_b": "value_b"
}
A YAML mapping contains multiple key-value pairs
key_a: value_a
key_b: value_b
An HCL map contain multiple key-value pairs
tomap({
 key_a = "value_a"
 key_b = "value_b"
})
A Python list contains multiple items
[
 'item_0',
 'item_1'
]
A JSON array contains multiple elements
[
 "element_0",
 "element_1"
]
A YAML sequence contains multiple elements
- element_0
- element_1
An HCL list contains multiple elements
tolist([
 "element_0",
 "element_1",
])
A Python tuple contains multiple values
(
 'value_0',
 'value_0'
)
JSON doesn't support tuples YAML doesn't support tuples Tuple contains multiple values
[
 "value_0",
 "value_1",
]
A Python set contains multiple elements
{
 'element_0',
 'element_1'
}
JSON doesn't support sets YAML doesn't support sets Set contains multiple values
toset([
 "value_0",
 "value_1",
])

 

So if you really want to use exactly the right terms, the table above can help you.

XML and YANG terminology run their its own games and doesn't compare well with these four, so we will look closer at those terminology separate blog posts. 

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.