Overview

The Extract Object Path Block allows you to run JSONPath queries on objects or arrays. This block is particularly useful for extracting specific data from complex JSON structures, such as API responses or nested objects.

Key Features

  • Extract data using JSONPath queries
  • Support for objects, arrays, and other JavaScript values with properties
  • Ability to perform complex queries and filtering
  • Dynamic path construction using input ports

Inputs

object
object | any[] | string
required

The object, array, or string to query using the JSONPath.

path
string
required

The JSONPath query to use for extracting properties from the input object. Only available when “Use Path Input” is enabled in settings.

Outputs

match
any

The first value that matches the specified path. If no match is found, this output will be control-flow-excluded.

all_matches
any[]

An array of all values that match the specified path. If no matches are found, this output will run with an empty array.

Editor Settings

path
string
default:"$"

The JSONPath query to use for extracting properties from the input object. Uses JSONPath syntax.

usePathInput
boolean
default:false

When enabled, allows the path to be provided via an input port instead of being set in the settings.

Example: Extract a property from an object

  1. Create an Object Block with the following JSON:
    {
      "name": "John Doe",
      "age": 30
    }
    
  2. Add an Extract Object Path Block and connect the Object Block to it.
  3. Set the Path of the Extract Object Path Block to $.name.
  4. Run the flow. The Extract Object Path Block should output John Doe.

Error Handling

  • If the path is invalid or not provided, the block will throw an error
  • If the path is valid but no value is found, the match output will be control-flow-excluded and the all_matches output will run with an empty array
  • If the input object is undefined or null, it will be treated as null for the JSONPath query

FAQ

See Also