Overview
The Destructure Block is used to extract multiple values from an object or array at once. It uses JSONPath notation to navigate through the input value and extract the values at the specified paths. This block is similar to the Extract Object Path Block, but it allows you to specify multiple paths and extract multiple values at once, which can be more convenient than using multiple Extract Object Path blocks.- Inputs
- Outputs
- Editor Settings
Inputs
| Title | Data Type | Description | Default Value | Notes |
|---|---|---|---|---|
| Object | object | The object to extract values from. | (required) |
Example 1: Extract multiple properties from an object
-
Create an Object Block and set the value to the following:
-
Create a Destructure Block and set the Paths to
$.name,$.age, and$.job. -
Connect the Object Block to the
Objectinput of the Destructure Block. -
Run the flow. The Destructure Block should have three outputs:
$.namewith the valueJohn Doe,$.agewith the value30, and$.jobwith the valueEngineer.
Error Handling
If a path is invalid or does not exist in the input object, the corresponding output port will not be run.FAQ
Q: How is the Destructure Block different from the Extract Object Path Block? A: The Destructure Block is similar to the Extract Object Path Block, but it allows you to specify multiple paths and extract multiple values at once. This can be more convenient than using multiple Extract Object Path blocks to extract multiple paths. The Destructure Block does not allow you specify a path and extract every value at that path, which is possible with the Extract Object Path Block. Q: Can I use the Destructure Block to extract array values? A: Yes, you can use the Destructure Block to extract array values, but only with a known length. You can use paths such as$[0], $[1], etc. to extract values from an array. However, you cannot use paths such as $[*] or $[?] to extract all values from an array.
Q: What happens if a path does not exist in the input object?
A: If a path does not exist in the input object, the corresponding output port will not be run.

