Skip to content

JSON Extractor Node

This node is designed to extract specific pieces of information from a JSON object based on a structured set of parameters provided to the node. It’s particularly useful for dealing with complex, nested JSON data structures, allowing users to specify exactly which data should be extracted at various levels of the JSON hierarchy.


Inputs

JSON: The JSON object from which data will be extracted. This input expects a JSON object or array.

Params: The parameters defining which parts of the JSON object to extract. This input expects an array of parameter objects, each specifying a key in the JSON data and any sub-keys that should be extracted from the associated value.


Output

Output: The extracted data, structured according to the provided parameters. The output will mirror the structure defined in the ‘Params’ input, containing only the keys and sub-keys specified for extraction.


Properties

No configurable properties are available for this node. The extraction logic is entirely driven by the ‘Params’ input.


Usage

To use the JSON Extractor Node:

  1. Connect a JSON object or array to the ‘JSON’ input.
  2. Define your extraction parameters as an array of objects, each specifying a ‘key’ to extract and, optionally, ‘subkeys’ for nested data extraction. Connect this parameter array to the ‘Params’ input.
  3. The node will process the inputs and output the extracted data according to your parameters.

This node simplifies the process of extracting specific information from complex JSON structures, making it easier to transform, analyze, and visualize JSON data within your graph.

Example

Suppose you have the following JSON object:

{
"data": [
{
"user_name": "john_doe",
"posts": [
{
"title": "My First Post",
"likes": 150,
"comments": [
{
"user": "jane_doe",
"content": "Great post!"
},
{
"user": "alex_smith",
"content": "Looking forward to more!"
}
\]
},
{
"title": "Another Day, Another Post",
"likes": 200,
"comments": [
{
"user": "jane_doe",
"content": "Absolutely love it!"
}
\]
}
\]
}
\]
}

To extract the titles of all posts and the content of the first comment of each post for the first user, you would use the following parameters:

[
{
"key": "data",
"count": 1,
"subkeys": [
{
"key": "posts",
"subkeys": [
{
"key": "title"
},
{
"key": "comments",
"count": 1,
"subkeys": [
{
"key": "content"
}
\]
}
\]
}
\]
}
\]

Connect this parameter array to the ‘Params’ input, and the JSON object to the ‘JSON’ input. The output will be:

{
"data": [
{
"posts": [
{
"title": "My First Post",
"comments": [
{
"content": "Great post!"
}
\]
},
{
"title": "Another Day, Another Post",
"comments": [
{
"content": "Absolutely love it!"
}
\]
}
\]
}
\]
}

This example demonstrates how to use the JSON Extractor Node to navigate through nested arrays and objects to retrieve specific pieces of data based on your requirements.