Skip to content

JSON data structure syntax

JSON (JavaScript Object Notation) is a widely used standard for data structures in software engineering^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]. It is commonly used for Web APIs, configuration files, and database storage^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md].

Syntax Rules

JSON defines objects using opening and closing curly braces {}^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]. Arrays or lists are defined using square brackets []^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md].

Key-Value Pairs

Data is represented as key-value pairs where both keys and string values are enclosed in double quotes^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]. A colon separates the key from the value.

{
  "customerID" : "a",
  "firstName": "Bob",
  "lastName": "Smith"
}

Data Structures

Collections of objects can be stored within arrays^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]. An array is declared with square brackets, containing individual objects separated by commas^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md].

[{customer-1},{customer-2},{customer-3}]

Serialization Constraints

When programmatically generating JSON, data must typically be converted into standard dictionaries^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]. Custom objects or classes are generally not directly JSON serializable^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]. For example, in Python, an object like Customer must be converted to a dictionary representation (e.g., via __dict__) before being stored or transported^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md].

Sources

^[400-devops__09-Scripting-Language__python__introduction__part-3.json__README.md]