Here are a few examples of JSON messages:
- A simple JSON object representing a person’s name and age:
{
“name”: “John Smith”,
“age”: 30
}
- A JSON object representing a collection of books:
{
“books”: [
{
“title”: “The Great Gatsby”,
“author”: “F. Scott Fitzgerald”,
“year”: 1925
},
{
“title”: “To Kill a Mockingbird”,
“author”: “Harper Lee”,
“year”: 1960
},
{
“title”: “The Catcher in the Rye”,
“author”: “J.D. Salinger”,
“year”: 1951
}
]
}
- A JSON object representing a message with metadata and data payload:
{
“status”: “success”,
“code”: 200,
“data”: {
“id”: 1,
“name”: “Product 1”,
“price”: 9.99
}
}