This document outlines the functionality and usage of the JSON Reader node, which enables extracting specific values from JSON data.

Node Inputs

  • JSON String: A string containing valid JSON data from which values will be extracted
  • Keys: A comma-separated list of keys to extract from the JSON structure (e.g., ‘name,email,id’)

Node Output

  • Key Values: Each key defined in the input is exposed as a separate output value

Node Functionality

The JSON Reader node extracts specified pieces of information from a JSON structure. It takes a JSON string and a list of keys as input, then outputs the values associated with those keys. The node processes one level of the JSON structure at a time.

When to Use

Use the JSON Reader node when you need to:

  • Extract specific fields from API responses
  • Process JSON data from files or other sources
  • Convert JSON values into individual outputs for further processing
  • Filter specific keys from larger JSON structures

Working with Nested JSON

For nested JSON structures, you’ll need to use multiple JSON Reader nodes in sequence. Each node can process one level of the JSON structure.

Example: Processing Nested JSON

Given this JSON structure from an API response:

{
  "success": true,
  "data": {
    "title": "Product Update",
    "content": "New features released",
    "metadata": {
      "author": "John Doe",
      "date": "2024-01-30"
    }
  }
}

To access nested values, create a chain of JSON Reader nodes:

  1. First JSON Reader:

    • Input: Original JSON string
    • Keys: “data”
    • Output: The entire data object
  2. Second JSON Reader:

    • Input: Output from first reader
    • Keys:
      1. title
      2. content
    • Output: Individual title and content values
  3. Third JSON Reader (for metadata):

    • Input: Output from second reader’s metadata
    • Keys:
      1. author
      2. date
    • Output: Individual author and date values

Example Use Cases

1. API Response Processing

{
  "status": "success",
  "results": {
    "userId": "12345",
    "username": "johndoe",
    "email": "john@example.com"
  }
}

Keys to extract: “status”

2. Configuration Data

{
  "settings": {
    "theme": "dark",
    "language": "en",
    "notifications": true
  },
  "version": "2.0.0"
}

Keys to extract: “version”

Working with Arrays

When dealing with JSON arrays, use the List Operations nodes in conjunction with the JSON Reader:

  1. Use JSON Reader to extract the array
  2. Use Get List Item to access specific array elements
  3. Use another JSON Reader to extract values from each array element

Important Considerations

  1. Key Sensitivity: Keys are case-sensitive
  2. Invalid JSON: Ensure your JSON string is valid before processing
  3. Nested Structures: Use multiple JSON Reader nodes for nested data
  4. Array Handling: Combine with List Operations nodes for array processing

Tips for Success

  1. Validate JSON First: Use the If/Else node to check if the JSON is valid
  2. Chain Readers: For nested structures, chain multiple JSON Reader nodes
  3. Use with Error Shield: Wrap JSON operations in Error Shield nodes to handle invalid JSON gracefully
  4. Preview Data: Use the debugger to preview JSON structure before setting keys
  • Write JSON Value: For modifying JSON data
  • Call API: For fetching JSON from APIs
  • If/Else: For conditional JSON processing
  • Error Shield: For handling JSON parsing errors
  • Custom Node: For creating a customized JSON parser that can handle:
    • Nested key extraction using dot notation
    • Complex array operations
    • Dynamic key mapping
    • Custom parsing logic
    • Automatic type conversion