What is Yaml?

YAML is a way to organize and store data in a format that’s easy for both humans and computers to read. It’s commonly used for creating configuration files. Some say YAML stands for “yet another markup language,” highlighting its purpose for data, not documents. YAML is liked in programming because it’s simple to read and work with. It can be used alongside other programming languages. Ansible, a tool for automation, uses YAML in its playbooks to define tasks and processes easily.

YAML Syntax Example?

#Comment: Student record
#Describes some characteristics and preferences
---
name: Martin D'vloper #key-value
age: 26
hobbies: 
  - painting #first list item
  - playing_music #second list item
  - cooking #third list item
programming_languages:
  java: Intermediate
  python: Advanced
  javascript: Beginner
favorite_food: 
  - vegetables: tomatoes 
  - fruits: 
      citrics: oranges 
      tropical: bananas
      nuts: peanuts
      sweets: raisins

What is YAML used for?

YAML is a widely used language for organizing and storing data in a way that’s simple for both people and computers to grasp. It’s known for being easy to read and understand, making it popular in the programming world. It’s not exactly a programming language itself, but it plays well with other programming languages.

What is json?

JSON means JavaScript Object Notation and has been used since the early 2000s. It got its start from JavaScript but works with many languages, not just JavaScript.Almost all modern programming languages can work with JSON using special tools or libraries. JSON is better than XML in many ways. It’s easier for people to read, more straightforward, and takes up less space. It’s excellent for storing and sending information between web applications and servers on the internet.

JSON version

{
	"Employees": [
    {
	"name": "John Doe",
	"department": "Engineering",
	"country": "USA"
		},

		{
		"name": "Kate Kateson",
		"department": "IT support",
		"country": "United Kingdom"
		}
	]
}

JSON Data Types and Examples

JSON can be used in JavaScript programs without any need for parsing or serializing. It’s a text-based way of representing JavaScript object literals, arrays, and scalar data.

JSON is relatively easy to read and write while also easy for software to parse and generate. It’s often used for serializing structured data and exchanging it over a network, typically between a server and web applications.
At the granular level, JSON consists of data types.

  • Array
  • Boolean
  • Null
  • Number
  • Object
  • String

Array

An array data type is an ordered collection of values. In JSON, array values must be of type string, number, object, array, Boolean, or null.
Example :-

{

"Influencers" :   [ 
{
 "name" : "Jaxon", 
 "age" : 42, 
 "Works At" : "Tech News"
}

{
 "name" : "Miller", 
 "age" : 35
 "Works At" : "IT Day"
}

] 
}
Boolean
Boolean values are designated as either true or false. Boolean values aren’t surrounded by quotes and are treated as string values.

Example
{ "AllowPartialShipment" : false }

Null
Null is an empty value. When no value is assigned to a key, it can be treated as null.
Example :-
{ "Special Instructions" : null }

Number
A JSON number follow JavaScript’s double-precision floating-point format.

Example
{
  "number_1" : 210,
  "number_2" : 215,
  "number_3" : 21.05,
  "number_4" : 10.05
}
Object

A JSON object data type is a set of name or value pairs inserted between {} (curly braces). The keys must be strings and separated by a comma and should be unique.

Example
{
  "Influencer" :   { "name" : "Jaxon" ,  "age" : "42" ,  "city" ,  "New York" }
}

String
A string in JSON is composed of Unicode characters, with backslash (\) escaping.

Example

{ "name" : "Jones" }

Leave a Comment