JSON Syntax is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is derived from JavaScript object notation but is language-independent.
Core Structure
Data is organized in key-value pairs, where each key must be a string enclosed in double quotes (
"key"), followed by a colon (:), and then a value.Objects are enclosed in curly braces
{}and contain zero or more key-value pairs, separated by commas.Arrays are enclosed in square brackets
[]and contain zero or more values of any type, also separated by commas.
Valid Data Types
JSON supports six data types:
String: A sequence of Unicode characters, enclosed in double quotes (
"example").Number: A signed decimal number, including integers and floating-point values (e.g.,
42,-3.14).Boolean: Either
trueorfalse(lowercase only).Null: Represents the absence of a value (
null).Object: A collection of name-value pairs (
{"name": "value"}).Array: An ordered list of values (
[1, "two", true]).
Key Rules
No trailing commas are allowed after the last item in an object or array.
No comments are allowed (
//,/* */, or#).Keys must be strings in double quotes — single quotes are invalid.
Values must be one of the six valid types — functions, dates,
undefined,NaN,Infinity, and-Infinityare not valid in JSON.Whitespace is allowed but insignificant — spaces, tabs, line feeds, and carriage returns can appear around structural characters.
Example
{
"name": "Alice",
"age": 30,
"isStudent": false,
"grades": [85, 90, 78],
"address": {
"street": "123 Main St",
"city": "Wonderland"
}
}This format is widely used in APIs, configuration files, and data storage due to its simplicity and compatibility across programming languages.