Skip to content

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:

  1. Choose the source – It checks that you’ve supplied exactly one of the inputs (file upload, file path, or string).
  2. 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.
  3. Parse the JSON – It tries to parse the text with Python’s json.loads.
  4. Repair if needed – If parsing fails, it uses the repair_json helper to fix common formatting mistakes and parses again.
  5. Create Data objects
    • If the parsed result is a list, it creates a separate Data object for each item.
    • If it’s a single object, it creates one Data object.
  6. Return the result – The component outputs the Data object(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 Data object (or a list of Data objects) 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

  1. Upload a file

    • Drag and drop a sample.json file into the JSON File field.
    • Click Run.
    • The component outputs a Data object that you can feed into a “Data to CSV” component to export the data.
  2. Enter a string

    • In the JSON String field, paste:
      {"name":"Alice","age":30}
    • Click Run.
    • The output Data object now contains the name and age, ready for further processing.

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.

  • 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 Data output 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 Data objects 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.