JSON to Data
The JSON to Data component lets you take any JSON input—whether it’s a file you upload, a path to a file on your system, or a raw JSON string—and turn it into a Data object that can be used elsewhere in your Nappai workflow. It’s a quick way to bring structured data into the automation system without writing any code.
How it Works
When you provide one of the three inputs, the component follows these steps:
- Choose the source – It checks that you’ve supplied exactly one of the inputs (file upload, file path, or string).
- Read the JSON –
- If you uploaded a file or gave a path, it reads the file’s contents.
- If you typed a string, it uses that directly.
- Parse the JSON – It tries to parse the text with Python’s
json.loads. - Repair if needed – If parsing fails, it uses the
repair_jsonhelper to fix common formatting mistakes and parses again. - Create Data objects –
- If the parsed result is a list, it creates a separate
Dataobject for each item. - If it’s a single object, it creates one
Dataobject.
- If the parsed result is a list, it creates a separate
- Return the result – The component outputs the
Dataobject(s) for downstream components to use.
No external APIs are called; everything happens locally inside Nappai.
Inputs
- JSON File: Upload a JSON file to convert to a Data object or list of Data objects.
- JSON File Path: Provide the path to the JSON file as pure text.
- JSON String: Enter a valid JSON string (object or array) to convert to a Data object or list of Data objects.
Outputs
- Data: A
Dataobject (or a list ofDataobjects) that contains the parsed JSON content. This output can be connected to other components that accept Data, such as data processors, storage modules, or AI models.
Usage Example
-
Upload a file
- Drag and drop a
sample.jsonfile into the JSON File field. - Click Run.
- The component outputs a
Dataobject that you can feed into a “Data to CSV” component to export the data.
- Drag and drop a
-
Enter a string
- In the JSON String field, paste:
{"name":"Alice","age":30}
- Click Run.
- The output
Dataobject now contains the name and age, ready for further processing.
- In the JSON String field, paste:
Remember: Only one of the three inputs should be used at a time. If you provide more than one, the component will raise an error.
Related Components
- Data to JSON – Convert a Data object back into a JSON string or file.
- JSON Validator – Check whether a JSON string is syntactically correct before feeding it into this component.
- File Reader – Read the contents of a file and output raw text, which can then be passed to this component as a string.
Tips and Best Practices
- Validate first: Use the JSON Validator component to catch errors early.
- Keep it simple: If your JSON is large, consider uploading a file instead of pasting a long string.
- Use repair wisely: The automatic repair feature helps with minor formatting issues, but it’s best to provide clean JSON to avoid unexpected changes.
- Check the output: After running, inspect the
Dataoutput in the preview pane to confirm the structure matches your expectations.
Security Considerations
- File access: When using the file path input, ensure the path points to a safe location. Avoid exposing sensitive directories.
- Input validation: The component repairs malformed JSON, but it still parses the content. Never feed untrusted JSON that could contain malicious code or large payloads that might exhaust memory.
- Data handling: The resulting
Dataobjects are stored in Nappai’s internal memory. If you’re working with confidential information, make sure your workflow follows your organization’s data‑handling policies.