Jeremy’s IT Lab lecture video:
Commands
No Commands :)
JSON, XML, & YAML Info
Data serialization is the process of converting data into a standardized format/structure that can be stored (in a file) or transmitted (over a network) and reconstructed later (by a different application).
- This allows the data to be communicated between applications in a way both applications can understand.
- Data serialization languages allow us to represent variables with text.
![]() |
---|
Example of Data Serialization |
Data Serialization Languages
There are three different data serialization languages you need to know for the CCNA, being:
- JSON
- XML
- YAML
1. JSON
JavaScript Object Notation (JSON) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects.
- It was derived from JavaScript, but it is language-independent and many modern programming languages are able to generate and read JSON data.
JSON Properties
- JSON is very human-readable
- REST APIs often use JSON.
- Whitespace is insignificant
- JSON can represent four ‘primitive’ data types
- String
- A string is a text value. It is surrounded by double quotes ” ”.
- Examples: ( “Hello.” | “five” | “5” | “true” | “null” )
- Number
- A number is a numeric value. It is not surrounded by quotes.
- Examples: ( 5 | 100 )
- Boolean
- A boolean is a data type that has only two possible values. It is not surrounded by quotes.
- ( true | false )
- Null
- A null value represents the intentional absence of any object value. It is not surrounded by quotes.
- ( null )
- String
- JSON also has two ‘structured’ data types:
- Object
- Sometimes called a dictionary
- An object is an unordered list of key-value pairs (variables)
- The key is a string.
- The value is any valid JSON data type (string, number, boolean, null, object, array).
- The key and value are enclosed with curly brackets ( { } )
- The key and value are separated by a colon ( : )
- If there are multiple key-value pairs, each pair is separated by a comma ( , )
- Objects within objects are called ‘nested objects’.
- Array
- Values are enclosed with square brackets ( [ ] )
- An array is a series of values separated by commas ( , )
- The values can be any type of data type.
- The values don’t have to be the same data type.
- Object
![]() |
---|
JSON Object Example (1) |
![]() |
---|
JSON Object Example (2) |
![]() |
---|
JSON Object Example (3) |
![]() |
---|
JSON Array Example (4) |
2. XML
Extensible Markup Language (XML) was developed as markup language, but is now used a general data serialization language.
XML Properties
- XML is generally less human-readable than JSON.
- REST APIs often use XML.
- Whitespace is insignificant.
- XML is represented as key-value pairs.
- It is presented as
<key>value</key>
.
![]() |
---|
XML Example (1) |
3. YAML
Yet Another Markup Language (YAML) is also used a data serialization language.
- YAML is used by the network automation tool Ansible.
YAML Properties
- YAML is the most human-readable language.
- Whitespace is significant (unlike JSON and XML). That means that indentation is very important.
- YAML files start with
---
. -
is used to indicate a list.- Keys and values are represented as
key:value
![]() |
---|
YAML Example (1) |