Sometimes, you may be tasked with consuming an API and the documentation is not present or you're not using
a library that can objectify your JSON for you. In these instances, it can be helpful to examine the response.
If you don't have a way to prettify your JSON, this JSON Formatter can help you see what attributes are available
and how they're structured. Here's an example:
Looking at the response like this is difficult to deal with. Just drop it into the JSON Formatter and it'll come out like this:
Now, it's very easy to see that "orders" is an array that contains two objects, each with four attributes. Much easier to deal with!
{"id":"u123","name":"John Doe","email":"john@example.com","isActive":true,"orders":[{"orderId":"o456","product":"Book","quantity":2,"price":15.99},{"orderId":"o789","product":"Laptop","quantity":1,"price":999.99}]}
{
"id": "u123",
"name": "John Doe",
"email": "john@example.com",
"isActive": true,
"orders": [
{
"orderId": "o456",
"product": "Book",
"quantity": 2,
"price": 15.99
},
{
"orderId": "o789",
"product": "Laptop",
"quantity": 1,
"price": 999.99
}
]
}