JSON Examples

Common JSON data structure examples, copy with one click

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on JavaScript object literal syntax, but is language-independent, with almost all modern programming languages supporting JSON parsing and generation.

JSON has the following characteristics:

  • Easy for humans to read and write
  • Easy for machines to parse and generate
  • Text-based, completely language-independent
  • Widely used for data transmission in web applications

Simple Object

Basic JSON object structure

{
  "name": "John Doe",
  "age": 30,
  "city": "New York"
}

User Profile

User information with nested objects

{
  "id": 1,
  "name": "Alice Smith",
  "email": "alice@example.com",
  "profile": {
    "avatar": "https://example.com/avatar.jpg",
    "bio": "Software Developer",
    "location": "San Francisco"
  },
  "preferences": {
    "theme": "dark",
    "notifications": true
  }
}

Product List

JSON array containing multiple product objects

[
  {
    "id": "p001",
    "name": "Laptop",
    "price": 999.99,
    "category": "Electronics",
    "inStock": true
  },
  {
    "id": "p002",
    "name": "Mouse",
    "price": 29.99,
    "category": "Accessories",
    "inStock": false
  }
]

API Response

Typical REST API response format

{
  "status": "success",
  "code": 200,
  "message": "Data retrieved successfully",
  "data": {
    "users": [
      {
        "id": 1,
        "name": "John",
        "role": "admin"
      },
      {
        "id": 2,
        "name": "Jane",
        "role": "user"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 10,
      "total": 25
    }
  },
  "timestamp": "2024-01-01T12:00:00Z"
}

Config File

Application configuration JSON

{
  "app": {
    "name": "MyApp",
    "version": "1.2.0",
    "environment": "production"
  },
  "database": {
    "host": "localhost",
    "port": 5432,
    "name": "myapp_db",
    "ssl": true
  },
  "features": {
    "authentication": true,
    "logging": true,
    "analytics": false
  }
}

Nested Array

Complex structure with multiple levels of nesting

{
  "company": "Tech Corp",
  "departments": [
    {
      "name": "Engineering",
      "teams": [
        {
          "name": "Frontend",
          "members": [
            "Alice",
            "Bob",
            "Charlie"
          ]
        },
        {
          "name": "Backend",
          "members": [
            "David",
            "Eve",
            "Frank"
          ]
        }
      ]
    },
    {
      "name": "Marketing",
      "teams": [
        {
          "name": "Digital",
          "members": [
            "Grace",
            "Henry"
          ]
        }
      ]
    }
  ]
}

Error Response

API error response example

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input parameters",
    "details": [
      {
        "field": "email",
        "message": "Email format is invalid"
      },
      {
        "field": "password",
        "message": "Password must be at least 8 characters"
      }
    ]
  },
  "timestamp": "2024-01-01T12:00:00Z",
  "requestId": "req_123456789"
}

GeoJSON

Geographic location data format

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -74.006,
          40.7128
        ]
      },
      "properties": {
        "name": "New York City",
        "population": 8336817
      }
    }
  ]
}

Package.json

Node.js project configuration file

{
  "name": "my-project",
  "version": "1.0.0",
  "description": "A sample Node.js project",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "jest",
    "build": "webpack --mode production"
  },
  "dependencies": {
    "express": "^4.18.0",
    "lodash": "^4.17.21"
  },
  "devDependencies": {
    "jest": "^29.0.0",
    "webpack": "^5.74.0"
  }
}

Mixed Data Types

Example containing various JSON data types

{
  "string": "Hello World",
  "number": 42,
  "float": 3.14159,
  "boolean": true,
  "nullValue": null,
  "array": [
    1,
    "two",
    true,
    null
  ],
  "object": {
    "nested": "value"
  },
  "emptyArray": [],
  "emptyObject": {}
}

功能特性

Rich Examples

Provides 10 common JSON data structure examples

One-Click Copy

Click to copy JSON code to clipboard instantly

Syntax Guide

Detailed JSON syntax rules and data type explanations

Privacy Safe

All operations are performed locally, no data uploaded

Frequently Asked Questions

Yes, all examples are valid JSON format and can be copied and used directly. You can modify the data as needed.
JSON syntax is simple and easy to learn. It mainly includes objects, arrays, strings, numbers, booleans, and null. Strings must be surrounded by double quotes, key-value pairs are separated by colons.
JSON is a data format, while JavaScript objects are data structures in programming language. JSON requires keys to be strings surrounded by double quotes, while JavaScript object keys can be without quotes.
You can use our JSON validator tool to check if JSON format is correct. It will point out the specific location of syntax errors.
JSON supports six basic data types: objects (using curly braces), arrays (using square brackets), strings (must use double quotes), numbers, booleans (true/false), and null.
This is a requirement of the JSON specification. Unlike JavaScript objects, JSON is a strict data format where all keys must be strings surrounded by double quotes, ensuring cross-language compatibility.