JSON Cheat Sheet

JavaScript Object Notation (JSON) is a lightweight, text-based, language-independent data interchange format. It was derived from the ECMAScript Programming Language Standard. JSON defines a small set of formatting rules for the portable representation of structured data.

💡 For JSON attacks, see JSON Injection and JSON Hijacking.

MIME media type

Content-Type: application/json

File extension

<filename>.json

JSON Examples

One city

{"id":1,"name":"Montreal"}

List of cities

[
    {"id":1,"name":"Montreal"},
    {"id":2,"name":"Toronto"},
    {"id":3,"name":"Vancouver"}
]

Supply multiple passwords during login

{"username":"victim","password":["whatever1","whatever2","whatever3"]}

One book with multiple authors

{
    "title":"My first book",
    "ISBN":"..."
    "authors":
    [
        {"firstname":"Bob", "lastname":"Foo"},
        {"firstname":"Alice", "lastname":"Smith"}
    ]
}

Two books

[
    {
        "title":"My first book",
        "ISBN":"..."
        "authors":
        [
            {"firstname":"Bob", "lastname":"Foo"},
            {"firstname":"Alice", "lastname":"Smith"}
        ]
    },
    {
        "title":"My second book",
        "ISBN":"..."
        "authors":{"firstname":"Bob", "lastname":"Foo"}
    }
]