Add Nested JSON Object in Postman Last Updated : 27 Jun, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Postman is a helpful tool for testing APIs and working with JSON. It lets you add nested objects to existing JSON. JSON is a simple data format for both humans and machines. Postman also lets developers send requests and view responses, which is really useful for working with JSON data.These are the following approaches to add Nested JSON object:Table of ContentManually define the nested structureLeverage pre-request scripts Manually define the nested structureIn your request, go to the "Body" tab.Select "raw" mode and choose "JSON (application/json)" from the dropdown menu. This ensures Postman interprets the data as JSON.Start defining your main object with key-value pairs.For nested objects, use curly braces {} within a key's value.Within these curly braces, define the nested object's key-value pairs. You can further nest objects within these nested objects for complex structures.Example: A JSON object representing a person named john doe and his address.{ "name": "John Doe", "address": { "street": "123 Main St", "city": "Anytown", "state": "CA", "zip": "12345" }}In this example, "address" is a nested object within the main object with its own key-value pairs.Leverage pre-request scripts Go to the "Tests" tab in your request. Click on "Pre-request Script" . Use libraries like JSON.parse and JSON.stringify to manipulate existing JSON data.You can parse existing JSON from a file or environment variable. Build the desired nested object structure within the script. Use JSON.stringify to convert the manipulated data back to a JSON string.Example: Parse the request body to JSON, add a nested object under a new key, and convert it back to a string. Update the request body in raw JSON format with the modified data.// Define your nested objectlet jsonData = JSON.parse( pm.request.body);let nestedObject = { "info": { "description": "This is some nested data" }}// Add the nested object to your main datajsonData.data = nestedObject;jsonData = JSON.stringify(jsonData);let body = { mode: 'raw', raw:jsonData, options: { raw: { language: 'json' } }}pm.request.body.update(body);adding nested data by pre-request script Comment More infoAdvertise with us Next Article How to add nested object to existing JSON using Postman ? H htomarec8c Follow Improve Article Tags : Web Technologies Node.js Postman-API-Testing Similar Reads How to add nested object to existing JSON using Postman ? Postman has become a critical tool for developers around the world, particularly when dealing with JSON data. This article will guide you through the process of adding nested objects to an existing JSON using Postman, with a focus on the approaches and syntax involved. Table of Content Understanding 4 min read How to read Array of Nested JSON Response in Postman ? We know that the postman is the one who delivers the letters sent by your friends, colleagues, or relatives and acts as a bridge of communication. Here Postman refers to the development of API that acts as a bridge or communication between different programs. In other words, it is an API client, mad 3 min read Manage API data and workflows using Postman JavaScript objects Managing API data and workflows efficiently is very important for developers. Postman, a popular API development environment, provides powerful tools to streamline this process. One such tool is Postman JavaScript objects, which allow you to manipulate data and automate workflows effectively. In thi 2 min read How to Upload File and JSON Data in Postman? Postman is a very famous API development tool used to test APIs. Postman simplifies the process of the API lifecycle to create and test better APIs. Now, while we are working with APIs sometimes we need to send JSON as data or upload a file through API. There may be a scenario where we have to do bo 4 min read Create, Use, and Run Postman Collections Postman Collections are a powerful feature that enables users to organize and manage API testing and development. Collections consist of requests, which are APIs with a request and response format. In this article, we study the creation, utilization, and execution of Postman Collections with example 4 min read How to create an environment in Postman? Postman is a popular API testing tool that is used to simplify the process of developing and testing APIs (Application Programming Interface). API acts as a bridge between two software applications which enables them to communicate and share data. Postman provides a simple Graphical User Interface f 3 min read Like