Last time we learned how APIs let applications request specific data. But what format does that data arrive in?
When a server sends back data through an API, it needs to package it in a way that's easy for the other application to understand and use.
Engagement Message
What is one quality that makes a data format easy for both computers and humans to read?
Meet JSON—JavaScript Object Notation! This is the most popular data format for sending data through APIs.
Think of JSON like a standardized takeout container. No matter what restaurant you order from, the food arrives in a predictable, organized way.
Engagement Message
Give one reason why a standard format is helpful for different apps.
Here's what simple JSON looks like:
Notice how it's organized in pairs—each piece of information has a label and a value.
Engagement Message
What are the three labels in this JSON example?
JSON is designed to be human-readable. Even without training, you can probably guess what this data represents!
The structure uses familiar punctuation: curly braces {}
to contain an object, and commas ,
to separate each piece of information.
Engagement Message
In one sentence, what does this JSON data tell us about Sarah?
Each piece of information in JSON is called a key-value pair. The key is the label (like "name"
) and the value is the actual data (like ).
