Learning Outcome
5
Connect JSON to Generative AI responses
4
Apply the right json function to real tasks.
3
Recognize how JSON maps to Python types
2
Identify JSON’s strict syntax rules.
1
Understand what JSON is and why it’s used.
Imagine goods being shipped from Mumbai to different parts of the world.
Standard Shipping Container
The same container works across different ships, cranes, and trucks without repacking.
Packing the Container
Putting goods into the standard container is like serialisation—converting data into JSON.
Standard Shipping Container
The same container works across different ships, cranes, and trucks without repacking.
Packing the Container
Putting goods into the standard container is like serialisation converting data into JSON.
Unpacking the Container
Taking the goods out at the destination is like deserialisation converting JSON back into usable data.
A Java server sends data to your Python script. Each stores data differently. How does it arrive usable?
Both agree on one standard container, JSON. One packs, the other unpacks.
So what does this container look like inside?
What is JSON
JavaScript Object Notation is a lightweight, text-based format that any language can read.
JSON Syntax Rules
Keys use double quotes: "name", never name
Strings use double quotes only; no 'Priya'.
true, false, and null are lowercase.
No trailing commas.
No comments.
Python dicts allow all of these. JSON allows none
Python's JSON Module
“s” means string. Load = unpack; dump = pack. response.json() = json.loads(response.text).
indent=2, ensure_ascii=False (Hindi text, with utf-8), sort_keys=True
Python's JSON Module
.get("email")
returns None instead of raising a KeyError
Type error
on dump means a set or date; use list(), .isoformat(), or default=str
JSON Decoded Error
means invalid text (single quotes, trailing comma, HTML page), so catch it with try-except.
Access like normal Python: data["student"]["courses"][0]
JSON Vs Python Dictionary
Real-World Application : Valid or Invalid JSON ?
{'name': 'Priya', 'age': 22} → Invalid: single quotes
{"name": "Rahul", "placed": True}→ Invalid: capital True
{"course": "Data Science", "batch": null} → Valid
{"city": "Pune", "pincode": 411001,} → Invalid: trailing comma
Why JSON Matters for Generative Ai
Prompts are sent as JSON via requests.post(url, json=payload)
AI responses come back as nested JSON
You can ask a model to answer in JSON, e.g. {"sentiment": "positive"}, then parse it with json.loads().
Models often add extra text or code, so strip them and wrap the parse in try-except
Transition from Analogy to Technical Concept(Slide 5)
Core Concepts (Slide 6)
Core Concepts (Slide 7)
Core Concepts (.....Slide N-3)
Summary
5
Build strong branding
4
Use different marketing channels
3
Target the right audience
2
Create and communicate value
1
Understand customer needs
Choose cool, soft colors instead of vibrant colors
Max 5 Points for Summary & Min 2
Quiz
Which platform is mainly used for professional networking and B2B marketing ?
A. Facebook
B. Instagram
C. LinkedIn
D. Snapchat
Quiz-Answer
Which platform is mainly used for professional networking and B2B marketing ?
A. Facebook
B. Instagram
C. LinkedIn
D. Snapchat