Select data from a complex JSON response
Selecting and processing data from responses is a fundamental function in Postman Flows. Understanding how to pull data from specific fields in a response is vital to designing effective flows. For example, you might want to extract an address field from several levels down in a complex JSON object from an API response.
Recipe
The following recipe shows how to extract a specific field from a complex JSON response:
-
Create a flow and add an HTTP Request block with a GET request to the following URL:
This will return a large, multi-leveled JSON object describing details about Apple Inc.
-
Connect a Select block to the HTTP Request block’s Success port.
-
Run the flow and click Enter path… in the Select block. A dropdown list appears showing the top-level fields in the JSON object from the response.
-
In the dropdown list, click the arrow next to body to view its nested fields.
-
Scroll down the body object and click the arrow next to the addresses field. More nested fields appear.
-
Click the arrow next to mailing to view its nested fields and select street1. The dropdown list closes and the following path appears in the Select block:
-
Run the flow and click the Select block’s Output tab view the street1 field’s value.
Pulling specific data from a complex JSON response lets you isolate that data so you can use it in the flow’s logic.
Try it out
To see this recipe’s completed flow, check out Cookbook: Select data from a complex JSON response. You can also clone this flow to your workspace to experiment with it.