MODULE 0: JSON, YAML & PYTHON, API & GIT
JSON - [Link]
• Introduction to JSON
• Working with JSON in Code
• Using JSON in APIs and Real-World Use Cases
• Validating and Formatting JSON
• Hands-on using JSON
YAML - [Link]
• What is YAML and Use cases & components of YAML
• YAML vs JSON
• YAML Design goals
• Defining a matrix with YAML
• Use cases of YAML. Ex: configuration files, DevOps, Kubernetes
• Reading YAML with Python
• Working with YAML in Code. Common libraries and tools
• Hands-on writing, reading and structuring YAML files for configuration management,
automation etc
API FUNDAMENTALS - [Link]
• Understanding APIs and Their Purpose
• Exploring REST API Architecture and Key Concepts
• Making API Requests and Handling Responses
• API Authentication and Security
• Hands-On with APIs Using Postman and Code
GIT - [Link]
• Introduction to Version Control and Git
• Git Core Concepts and Workflow
• Working with Git Repositories and Branches
• Hands-On Practice with Git Commands
Documentation:
Link - [Link]
Link 2 - [Link]
Link 3 - [Link]
Link 4 - [Link]
1. Introduction to JSON
What is JSON?
JSON (JavaScript Object Notation) is a lightweight data-interchange format used to store
and exchange data between a client and a server.
Why JSON is Used
● Easy for humans to read and write
● Easy for machines to parse and generate
● Language-independent
● Widely used in APIs, web services, and cloud applications
JSON Structure
JSON is based on key–value pairs and supports:
● Objects → { }
● Arrays → [ ]
Example:
{
"name": "Kowsick",
"age": 22,
"skills": ["Python", "SQL", "Cloud"],
"isStudent": true
}
Data Types Supported in JSON
● String
● Number
● Boolean (true, false)
● Array
● Object
● Null
❌ JSON does not support functions or comments.
JSON vs Python Dictionary
JSON Python Dict
true True
null None
Double quotes only Single or double
quotes
Uses of JSON
● REST API request & response
● Data storage & configuration files
● Mobile and web applications
● Cloud data exchange
JSON in Python
import json
data = '{"name":"Kowsick","age":22}'
parsed = [Link](data)
print(parsed["name"])
In One Line (Interview Answer):
“JSON is a lightweight, text-based format used to exchange data between client and
server in a structured way.”
2. Working with JSON in Python
Python provides a built-in module called json to work with JSON data.
1. Convert JSON String → Python Object
([Link]())
import json
json_data = '{"name":"Kowsick","age":22,"skills":["Python","SQL"]}'
python_obj = [Link](json_data)
print(python_obj)
print(python_obj["name"])
✔ Output
{'name': 'Kowsick', 'age': 22, 'skills': ['Python', 'SQL']}
Kowsick
2. Convert Python Object → JSON String
([Link]())
import json
data = {
"name": "Kowsick",
"age": 22,
"active": True
json_string = [Link](data)
print(json_string)
3. Read JSON Data from a File
([Link]())
[Link]
{
"id": 101,
"product": "Laptop",
"price": 50000
Python Code
import json
with open("[Link]", "r") as file:
data = [Link](file)
print(data["product"])
4. Write Python Data to a JSON File
([Link]())
import json
data = {
"username": "admin",
"role": "tester"
with open("[Link]", "w") as file:
[Link](data, file, indent=4)
5. Pretty Print JSON
print([Link](data, indent=4))
6. Access Nested JSON
data = {
"user": {
"name": "Kowsick",
"skills": ["Python", "Cloud"]
print(data["user"]["skills"][0])
7. JSON Data Type Mapping
JSON Python
string str
number int / float
boolean True / False
null None
array list
object dict
8. JSON in API Response (Example)
import requests
response = [Link]("[Link]
data = [Link]()
print(data["name"])
Common Interview Question
Q: Difference between load and loads?
Function Usage
load() Read JSON from file
loads() Read JSON from
string
One-Line Interview Answer
“We work with JSON in Python using the json module to convert between JSON
strings/files and Python dictionaries or lists.”
3. Using JSON in APIs & Real-World
Use Cases
1. Why APIs Use JSON
JSON is the most common format used in APIs because it is:
● Lightweight
● Easy to read and parse
● Language independent
● Fast for data transfer
APIs usually send and receive data in JSON format.
2. JSON in API Request & Response
✔ Example: API Response (JSON)
"userId": 101,
"name": "Kowsick",
"email": "kowsick@[Link]",
"active": true
✔ Example: API Request (JSON)
"username": "admin",
"password": "admin123"
3. Using JSON in APIs (Python Example)
✔ GET Request (Receive JSON)
import requests
response = [Link]("[Link]
data = [Link]()
print(data["name"])
✔ POST Request (Send JSON)
import requests
payload = {
"name": "Kowsick",
"email": "kowsick@[Link]"
response = [Link](
"[Link]
json=payload
print(response.status_code)
4. JSON in Authentication APIs
Most login APIs use JSON.
Example:
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
"expiresIn": 3600
Used in:
● JWT Authentication
● OAuth Tokens
5. Real-World Use Cases of JSON
🛒 E-commerce
{
"product": "Laptop",
"price": 50000,
"stock": 10
Used for:
● Product details
● Orders
● Payment responses
🏦 Banking
{
"accountNo": "123456",
"balance": 45000,
"currency": "INR"
Used for:
● Balance check
● Transaction history
Healthcare
"patientId": "P101",
"heartRate": 72,
"temperature": 98.6
🏠 IoT Systems
{
"deviceId": "D1001",
"temperature": 30,
"humidity": 70
}
Used for:
● Sensor data transmission
● Real-time monitoring
☁️ Cloud Computing
JSON is used in:
● Cloud configuration files
● API gateways
● Serverless functions
6. JSON vs XML in APIs
JSON XML
Lightweight Heavy
Faster Slower
Easy to parse Complex
Widely used Less common
Interview One-Line Answer
“JSON is used in APIs to exchange structured data between client and server because it
is lightweight, fast, and language independent.”
4. Validating and Formatting JSON
1. What is JSON Validation?
JSON validation ensures that:
● The JSON syntax is correct
● The structure follows expected rules
● Required fields are present
● Data types are correct
❌ Invalid JSON can break APIs or applications.
2. Basic JSON Validation in Python
✔ Example: Validating JSON String
import json
json_data = '{"name":"Kowsick","age":22}'
try:
data = [Link](json_data)
print("Valid JSON")
except [Link]:
print("Invalid JSON")
3. Common JSON Errors
Error Reason
Single JSON requires double
quotes quotes
Trailing Not allowed
comma
Missing { } required
braces
Commen JSON doesn’t support
ts comments
❌ Example:
{ 'name': 'Kowsick', }
4. Formatting (Pretty Printing) JSON
✔ Convert ugly JSON → readable JSON
import json
data = {"name":"Kowsick","age":22,"skills":["Python","Cloud"]}
formatted = [Link](data, indent=4)
print(formatted)
5. Formatting JSON from File
import json
with open("[Link]", "r") as f:
data = [Link](f)
print([Link](data, indent=4))
6. Sorting JSON Keys
print([Link](data, indent=4, sort_keys=True))
7. JSON Schema Validation (Advanced)
Used to enforce structure & rules.
✔ Example Schema:
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"}
},
"required": ["name", "age"]
✔ Python Validation:
from jsonschema import validate
validate(instance=data, schema=schema)
8. Real-World Use Cases
● API request validation
● Data exchange between services
● Configuration file checks
● IoT device data validation
5. Hands-On Using JSON (Python)
1. Create JSON Data
data = {
"id": 101,
"name": "Kowsick",
"role": "Developer",
"skills": ["Python", "SQL", "Cloud"]
2. Convert Python Object → JSON String
import json
json_data = [Link](data)
print(json_data)
3. Convert JSON String → Python Object
parsed_data = [Link](json_data)
print(parsed_data["name"])
4. Write JSON to a File
with open("[Link]", "w") as file:
[Link](data, file, indent=4)
5. Read JSON from a File
with open("[Link]", "r") as file:
data = [Link](file)
print(data["skills"])
6. Validate JSON
try:
[Link](json_data)
print("Valid JSON")
except [Link]:
print("Invalid JSON")
7. Access Nested JSON
data = {
"user": {
"profile": {
"email": "kowsick@[Link]"
print(data["user"]["profile"]["email"])
8. Update JSON Data
data["role"] = "Senior Developer"
data["skills"].append("DevOps")
9. JSON with API (Real Use Case)
import requests
response = [Link]("[Link]
data = [Link]()
print(data["name"])
10. Pretty Print JSON
print([Link](data, indent=4))
11. Common Real-World Uses
✔ REST APIs
✔ Cloud configurations
✔ IoT sensor data
✔ Web & mobile apps
✔ Database exports
Interview Ready One-Liner
“I have hands-on experience creating, reading, validating, formatting, and using JSON in
APIs and real-world applications using Python.”
YAML (YAML Ain’t Markup Language)
1. What is YAML?
YAML is a human-readable data serialization language mainly used for configuration files,
automation scripts, and DevOps tools.
It is designed to be simple, clean, and readable.
2. Components of YAML
✔ Key-Value Pairs
name: Kowsick
age: 22
✔ Lists
skills:
- Python
- SQL
- Cloud
✔ Dictionaries (Maps)
address:
city: Chennai
country: India
✔ Indentation
● Spaces matter (no tabs)
● Controls hierarchy
3. Use Cases of YAML
✔ Configuration files
✔ CI/CD pipelines
✔ DevOps tools
✔ Kubernetes
✔ Ansible playbooks
✔ Docker Compose
4. YAML vs JSON
Feature YAML JSON
Readabili Very high Medium
ty
Syntax Indentation Brackets &
based commas
Commen Supported Not supported
ts
Used in DevOps, APIs
Config
Data size Compact Slightly larger
5. YAML Design Goals
● Easy to read and write
● Minimal syntax
● Language independent
● Supports complex data
● Friendly for configuration
6. Defining a Matrix in YAML
✔ Example: Matrix
matrix:
- [1, 2, 3]
- [4, 5, 6]
- [7, 8, 9]
✔ Alternative Format
matrix:
row1: [1, 2, 3]
row2: [4, 5, 6]
row3: [7, 8, 9]
7. YAML in DevOps & Kubernetes
✔ Kubernetes Example
apiVersion: v1
kind: Pod
metadata:
name: myapp
spec:
containers:
- name: app
image: nginx
✔ Docker Compose Example
version: "3"
services:
web:
image: nginx
ports:
- "80:80"
8. Reading YAML with Python
✔ Install Library
pip install pyyaml
✔ Read YAML File
import yaml
with open("[Link]", "r") as file:
data = yaml.safe_load(file)
print(data)
9. Writing YAML with Python
import yaml
data = {
"name": "Kowsick",
"role": "Developer",
"skills": ["Python", "Cloud"]
with open("[Link]", "w") as file:
[Link](data, file)
10. Working with YAML in Code
✔ Common Libraries & Tools
● PyYAML (Python)
● [Link] (Preserves formatting)
● Ansible
● Kubernetes
● Docker Compose
● GitHub Actions
11. Hands-On YAML Configuration Example
✔ [Link]
app:
name: TestApp
version: 1.0
database:
host: localhost
port: 3306
user: admin
✔ Python Code
import yaml
with open("[Link]") as f:
config = yaml.safe_load(f)
print(config["database"]["host"])
12. YAML Best Practices
✔ Use spaces, not tabs
✔ Keep indentation consistent
✔ Use comments for clarity
✔ Validate YAML before deployment
Interview One-Line Answer
“YAML is a human-readable configuration language widely used in DevOps, Kubernetes,
and automation tools.”
API Concepts :
Understanding APIs and Their Purpose
What is an API?
API (Application Programming Interface) allows two software applications to
communicate with each other.
Simple Example:
A mobile app requests data → server API → returns response in JSON.
Why APIs are Used
✔ Data sharing between systems
✔ Backend–frontend communication
✔ Mobile & web app integration
✔ Microservices communication
Real-World Example
● Google Maps API → map & location
● Payment Gateway API → payments
● Social Media APIs → login, posts
Exploring REST API Architecture & Key
Concepts
What is REST?
REST (Representational State Transfer) is an architectural style for designing APIs.
REST Key Principles
✔ Stateless
✔ Client–Server architecture
✔ Uniform interface
✔ Resource-based URLs
HTTP Methods
Method Purpose
GET Fetch data
POST Create data
PUT Update data
DELETE Remove data
REST API URL Example
[Link]
➡️ users = resource
➡️ 101 = resource ID
HTTP Status Codes
Code Meaning
200 OK
201 Created
400 Bad Request
401 Unauthorized
404 Not Found
500 Server Error
Making API Requests & Handling
Responses
API Response Format (JSON)
"id": 101,
"name": "Kowsick",
"email": "kowsick@[Link]"
}
API Call Using Python (GET)
import requests
response = [Link]("[Link]
if response.status_code == 200:
data = [Link]()
print(data["name"])
POST Request Example
payload = {
"name": "Kowsick",
"email": "kowsick@[Link]"
response = [Link](
"[Link]
json=payload
)
API Authentication & Security
🔹 Common Authentication Types
✔ API Key
✔ Basic Auth
✔ Token (JWT)
✔ OAuth
✔ API Key Example
Authorization: Api-Key xyz123
✔ JWT Token Example
Authorization: Bearer eyJhbGciOiJIUzI1Ni...
Security Best Practices
✔ Use HTTPS
✔ Token expiration
✔ Input validation
✔ Rate limiting
Hands-On with APIs Using Postman
🔹 Steps in Postman
1. Choose HTTP method
2. Enter API URL
3. Add headers (Authorization)
4. Send request
5. View response & status code
✔ Example (POST in Postman)
● Method: POST
● Body → raw → JSON
"name": "Kowsick",
"email": "kowsick@[Link]"
Hands-On with APIs Using Code
(Python)
✔ Authentication Example
headers = {
"Authorization": "Bearer YOUR_TOKEN"
}
response = [Link](
"[Link]
headers=headers
print([Link]())
Error Handling
if response.status_code != 200:
print("Error:", response.status_code)
Interview One-Line Answer
“APIs enable communication between applications, REST APIs use HTTP methods and
JSON, and I’ve worked with them using Postman and Python.”
Introduction to Version Control & Git
What is Version Control?
Version Control is a system that tracks changes in files over time, allowing multiple people to
work on the same project without conflicts.
Why Version Control is Important
✔ Tracks file history
✔ Allows rollback to previous versions
✔ Supports team collaboration
✔ Prevents code loss
What is Git?
Git is a distributed version control system that allows developers to manage source code
efficiently.
Popular Git Platforms
● GitHub
● GitLab
● Bitbucket
Git Core Concepts & Workflow
Core Concepts
Term Meaning
Repository Project storage
Commit Snapshot of changes
Branch Separate line of
development
Merge Combine branches
Clone Copy remote repo
Push Upload changes
Pull Download changes
Git Workflow
1. Working Directory – edit files
2. Staging Area – git add
3. Repository – git commit
4. Remote Repository – git push
Working with Git Repositories &
Branches
Create a Repository
git init
Clone a Repository
git clone [Link]
Check Repository Status
git status
Add Files to Staging Area
git add [Link]
git add .
Commit Changes
git commit -m "Initial commit"
Create a Branch
git branch feature-login
Switch Branch
git checkout feature-login
# OR
git switch feature-login
Merge Branch
git checkout main
git merge feature-login
Delete Branch
git branch -d feature-login
Hands-On Practice with Git Commands
View Commit History
git log
Pull Latest Changes
git pull origin main
Push Changes to Remote
git push origin main
Undo Changes
git checkout -- [Link]
Reset Commit
git reset --hard HEAD~1
Handle Merge Conflicts
1. Open conflicted file
2. Resolve manually
3. git add
4. git commit
Best Practices
✔ Commit frequently
✔ Use meaningful commit messages
✔ Create feature branches
✔ Pull before pushing
Interview One-Line Answer
“Git is a distributed version control system that tracks code changes and enables team
collaboration through branching and commits.”