JSON to Data
The JSON to Data component is designed to help you transform raw JSON data into a structured, organized format that is easy to work with in Nappai. Think of it as a bridge: it takes unstructured or semi-structured data (like a JSON dictionary or text) and turns it into a clean “Data Object.” This makes it much easier to filter, sort, visualize, or combine this data with other information in your automation workflows.
Whether you are pulling data from an API response or manually entering JSON snippets, this component ensures your data is ready for the next steps in your pipeline.
How it Works
This component acts as a data adapter. It receives JSON data and converts it into a standardized DataObject. This internal process involves:
- Validating the input to ensure it is proper JSON.
- Parsing the structure (whether it is a dictionary or plain text).
- Structuring the data into rows and columns or records that other components in Nappai can easily understand and manipulate.
If you provide a “Schema,” the component will also validate that your data matches the expected structure. If no schema is provided, it will automatically infer the structure from your data.
Connection & Credentials
This component does not require any external credentials or API keys to function. It processes data locally within your workflow.
Inputs
The following fields are available to configure this component.
- JSON: [DictInput] The JSON dictionary data to be converted. This is useful when you are connecting the output from another component that already provides data in a JSON format.
- JSON Text: [MultilineInput] Allows you to manually type or paste JSON text. Use this if you don’t have a data source connected yet and need to test with sample data.
- Mode: [DropdownInput] Choose how you want to provide your data:
- Data Entry: Connects to a JSON dictionary from another component.
- Manual Entry: Uses the text you type in the “JSON Text” field.
Outputs
The component produces two main outputs for you to use in subsequent steps:
- Data: This is the primary output. It contains your original JSON content now organized into a structured
DataObject. You can connect this to other components for filtering, aggregating, or visualizing. - Transformation Metadata: This provides information about the conversion process, such as the number of records processed or any warnings. This is helpful for debugging if something doesn’t look right in your data.
Output Data Example (JSON)
Here is a realistic example of the structured data you might see after using this component. It represents how a flat JSON dictionary is transformed into a usable data object: json { “records”: [ { “id”: “101”, “name”: “Alice Johnson”, “status”: “Active”, “score”: 95 }, { “id”: “102”, “name”: “Bob Smith”, “status”: “Inactive”, “score”: 88 } ], “metadata”: { “total_records”: 2, “source_type”: “manual_json” } }
Connectivity
This component is typically used at the beginning of a data processing chain.
Typical Connections:
- Incoming Data: It connects to components that generate JSON, such as:
- HTTP Requests (receiving API responses)
- Database Connectors (exporting data in JSON format)
- Code Components (generating JSON dictionaries)
- Outgoing Data: It feeds into components that need structured data, such as:
- Filter Rows (to remove unwanted records)
- Aggregate Data (to calculate sums or averages)
- Display Table (to visualize the data in a grid)
- Send Email (to format data for a message)
Why connect it this way? Most downstream components in Nappai (like filters or visualizations) expect data in a specific structured format (like rows and columns). This component ensures that raw JSON is converted into that expected format, preventing errors in later steps.
Usage Example
Scenario: Filtering Employee Data from an API
- Step 1: Use an HTTP Get component to fetch employee data from your HR system. The output is a JSON dictionary.
- Step 2: Connect the output of the HTTP component to the JSON input of the JSON to Data component.
- Step 3: The JSON to Data component converts this JSON into a structured table.
- Step 4: Connect the Data output to a Filter Rows component to show only employees with a “Status” of “Active”.
This flow ensures that the API response is properly structured before you try to filter specific employees.
Important Notes
ℹ️ Non-Obvious Behavior
- The order of fields in your output data may vary depending on the internal implementation of the base component. Do not rely on a specific column order unless you explicitly sort or map the data later.
- If you use Mode: Manual Entry, ensure your JSON text is valid (no trailing commas, correct quotes). Invalid JSON will cause the component to fail.
💡 Best Practice
- If you know the structure of your JSON data in advance, consider defining a Schema in advanced configurations (if available in your version) to enforce data types and catch errors early.
- Always check the Transformation Metadata output if a workflow fails, as it may contain helpful error messages about why the conversion didn’t work.
Tips and Best Practices
- Validate Early: If you are entering JSON manually, ensure it is valid before connecting it to complex workflows. Use a JSON validator tool outside of Nappai if you are unsure.
- Use Manual Entry for Testing: When building a new workflow, use the JSON Text input with small, sample datasets to test your logic before connecting it to live data sources.
- Check Data Types: Ensure that numbers in your JSON are treated as numbers and not text strings, especially if you plan to perform calculations later in your workflow.
Security Considerations
- Input Validation: Since this component processes data, ensure that the JSON input comes from trusted sources. Malformed or malicious JSON inputs could potentially cause errors in your workflow.
- No External API Calls: This component does not call any external APIs directly, reducing exposure to external security risks. It only processes the data provided to it.
Related Components
- Data to JSON: The reverse operation, converting structured data back into JSON format for exports or API responses.
- HTTP Get/Post: Often used as the source of JSON data for this component.
- Filter Rows: A common next step to refine the structured data produced by this component.