JSON (JavaScript Object Notation) is a lightweight, text-based format used to store and exchange structured data.
It represents information through key-value pairs and arrays, making it easy for applications to process and share data. JSON is widely used in web APIs, configuration files, databases, and web scraping.
Also known as: JSON format, JavaScript Object Notation.
JSON organizes data using objects and arrays.
An object contains key-value pairs, while an array contains an ordered list of values.
For example:
{
"product": "Wireless Mouse",
"price": 29.99,
"available": true,
"categories": ["Electronics", "Accessories"]
}
Applications can parse this JSON text into data structures and use the information for further processing.
JSON supports six main data types:
true or false.JSON can also contain nested objects and arrays to represent more complex information.
Both JSON and XML are used to exchange structured data.
JSON is commonly preferred for modern web APIs because it is lightweight and easy to process.
JSON and CSV are both popular data formats.
CSV works well for simple tabular datasets, while JSON is more suitable for hierarchical data.
JSON-LD extends JSON to represent linked data and semantic relationships.
JSON-LD is commonly used for structured data on websites.
JSON is widely used in web data collection because many APIs and dynamic websites return structured information in this format.
A typical workflow includes:
JSON responses can be easier to process than HTML because they already contain structured fields.
Suppose a weather application receives the following JSON data:
{
"location": "New York",
"current_conditions": {
"temperature": 72,
"humidity": 65,
"description": "Partly Cloudy"
},
"forecast": [
{
"day": "Monday",
"high": 75,
"low": 60
},
{
"day": "Tuesday",
"high": 78,
"low": 62
}
]
}
The application can access the current temperature, weather conditions, and daily forecast using the structured fields.
JSON is a lightweight data format that uses objects, arrays, and key-value pairs to organize information.
Its readability, flexibility, and broad compatibility make it a standard choice for APIs, web applications, configuration files, and web data exchange.