Parse JSON
Parse and extract values from JSON data using powerful JSONPath expressions.
Overview
Section titled “Overview”The Parse JSON action allows you to extract specific values from JSON data using JSONPath expressions. Perfect for handling complex API responses, processing webhook payloads, or extracting nested data from JSON strings.
Configuration
Section titled “Configuration”Input Fields
Section titled “Input Fields”JSON Data (Required)
Section titled “JSON Data (Required)”The JSON string you want to parse. This is typically the response from a webhook action or a property containing JSON data.
Example:
{"user":{"name":"John Doe","email":"john@example.com","age":30}}Or from a webhook:
{{action_123.rawOutput}}JSONPath Expression(s) (Required, up to 5)
Section titled “JSONPath Expression(s) (Required, up to 5)”One or more JSONPath expressions to extract values from the JSON data. You can specify up to 5 different paths to extract multiple values in a single action.
Syntax:
name- Simple property accessuser.name- Nested property accessitems[0]- Array access by indexitems[*].name- Get all names from array items$.user.profile.settings- Full JSONPath with $ root
Output Fields
Section titled “Output Fields”success (Boolean String)
Section titled “success (Boolean String)”Returns "true" if the JSON was parsed successfully, "false" if parsing failed.
error (String)
Section titled “error (String)”Contains an error message if parsing failed, empty if successful.
value1, value2, value3, value4, value5 (Strings)
Section titled “value1, value2, value3, value4, value5 (Strings)”The extracted values corresponding to each JSONPath expression you provided. If a path doesn’t exist or fails, the value will be empty.
JSONPath Syntax Guide
Section titled “JSONPath Syntax Guide”Simple Property Access
Section titled “Simple Property Access”name → Extract "John Doe"email → Extract "john@example.com"age → Extract 30Nested Object Access
Section titled “Nested Object Access”user.profile.name → Extract nested valueuser.profile.location → Extract deep nested valuesettings.preferences.theme → Multiple levels deepArray Element Access
Section titled “Array Element Access”users[0] → Get first user objectitems[2].name → Get name from third itemprices[0] → Get first priceWildcard Array Access
Section titled “Wildcard Array Access”users[*].email → Get all email addressesitems[*].price → Get all pricesComplete Examples
Section titled “Complete Examples”Example 1: Parse User Data from API
Section titled “Example 1: Parse User Data from API”Scenario: You received user data from an API and want to extract name, email, and company.
Input JSON:
{ "success": true, "data": { "user": { "firstName": "John", "lastName": "Doe", "email": "john@example.com", "company": { "name": "Acme Corp", "domain": "acme.com" } } }}JSONPath Expressions:
data.user.firstNamedata.user.emaildata.user.company.namedata.user.company.domain
Output:
- value1:
"John" - value2:
"john@example.com" - value3:
"Acme Corp" - value4:
"acme.com"
Use: Update contact properties with these values
Example 2: Extract Items from Shopping Cart
Section titled “Example 2: Extract Items from Shopping Cart”Scenario: Parse order data to get first item details.
Input JSON:
{ "orderId": "ORD-12345", "items": [ { "productId": "PROD-001", "name": "Widget", "quantity": 2, "price": 29.99 }, { "productId": "PROD-002", "name": "Gadget", "quantity": 1, "price": 49.99 } ], "total": 109.97}JSONPath Expressions:
orderIditems[0].nameitems[0].quantityitems[0].pricetotal
Output:
- value1:
"ORD-12345" - value2:
"Widget" - value3:
"2" - value4:
"29.99" - value5:
"109.97"
Example 3: Parse Clearbit Enrichment Data
Section titled “Example 3: Parse Clearbit Enrichment Data”Scenario: Extract company data from Clearbit API response.
Input JSON:
{ "person": { "name": { "fullName": "John Doe" }, "employment": { "name": "Acme Corporation", "title": "VP of Sales", "role": "sales", "seniority": "executive" } }}JSONPath Expressions:
person.name.fullNameperson.employment.nameperson.employment.titleperson.employment.roleperson.employment.seniority
Output:
- value1:
"John Doe" - value2:
"Acme Corporation" - value3:
"VP of Sales" - value4:
"sales" - value5:
"executive"
Use: Enrich contact records with professional data
Example 4: Handle Array of All Items
Section titled “Example 4: Handle Array of All Items”Scenario: Get all product names from an order.
Input JSON:
{ "products": [ {"name": "Laptop", "sku": "LAP-001"}, {"name": "Mouse", "sku": "MOU-001"}, {"name": "Keyboard", "sku": "KEY-001"} ]}JSONPath Expression:
products[*].name
Output:
- value1:
"Laptop,Mouse,Keyboard"(returned as comma-separated string)
Example 5: Error Response Handling
Section titled “Example 5: Error Response Handling”Scenario: Parse both success and error scenarios from API.
Input JSON (Error):
{ "success": false, "error": { "code": "INVALID_EMAIL", "message": "Email address is invalid" }}JSONPath Expressions:
successerror.codeerror.message
Output:
- success:
"true"(JSON parsed successfully) - value1:
"false"(API returned success: false) - value2:
"INVALID_EMAIL" - value3:
"Email address is invalid"
Use: Branch on value1 to handle API errors
Best Practices
Section titled “Best Practices”- Test your JSON - Use JSONLint to validate JSON structure
- Test your paths - Use JSONPath Online Evaluator to verify expressions
- Handle missing values - Always check if output values are empty before using them
- Use with Webhook - Combine with Webhook action for API integrations
- Branch on success - Use if/then branches to handle parse failures
- Start simple - Begin with top-level properties, then go deeper
- Extract multiple values - Use all 5 paths to minimize action usage
- Handle arrays carefully - Remember array indices start at 0