WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

RESTful Web Services · Basic · question 13 of 100

What is JSON and how is it used in RESTful web services?

📕 Buy this interview preparation book: 100 RESTful Web Services questions & answers — PDF + EPUB for $5

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is commonly used in RESTful web services. JSON is easy to read and write, and is supported by most modern programming languages, including Java.

JSON is based on a key-value pair format and can represent simple or complex data structures. JSON data is often sent between clients and servers in HTTP requests and responses. In RESTful web services, JSON is commonly used as the data format for request and response payloads.

For example, let’s say we have a RESTful web service that manages orders for a coffee shop. When a client creates a new order, it might send a JSON payload like this:

    POST /orders HTTP/1.1
    Host: example.com
    Content-Type: application/json
    
    {
        "customer\_id": 123,
        "items": [
        {
            "name": "Cappuccino",
            "quantity": 1
        },
        {
            "name": "Croissant",
            "quantity": 2
        }
        ]
    }

In this example, the client sends a JSON payload that includes the customer ID and a list of items in the order. The server can then parse the JSON payload and use the data to create a new order in the system.

When the server responds to the client, it might send a JSON payload that includes the details of the new order:

HTTP/1.1 201 Created Content-Type: application/json

"id": 456, "customer_id": 123, "items": [ "name": "Cappuccino", "quantity": 1, "price": 2.99 , "name": "Croissant", "quantity": 2, "price": 2.00 ], "total": 6.99

In this example, the server sends a JSON payload that includes the details of the new order, including the order ID, customer ID, list of items, and total price.

In summary, JSON is a lightweight data-interchange format that is commonly used in RESTful web services to represent request and response payloads. JSON data is easy to read and write, and is supported by most modern programming languages, including Java.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic RESTful Web Services interview — then scores it.
📞 Practice RESTful Web Services — free 15 min
📕 Buy this interview preparation book: 100 RESTful Web Services questions & answers — PDF + EPUB for $5

All 100 RESTful Web Services questions · All topics