JSON Cleaner
JSON Cleaner receives a text that should be in JSON format, like the one a model returns when you ask for structured data, and fixes it so it is valid JSON: it removes extra text, closes braces and fixes quotes.
When to use it
- A model returns JSON data with some error and the next component fails.
- You want to make sure a model’s answer can be read as data.
Configuration
| Field | What it does |
|---|---|
| JSON String (required) | The text to clean. |
| Remove Control Characters | Removes invisible characters that can break the format. Off by default. |
| Normalize Unicode | Unifies how special characters, such as accents, are written. Off by default. |
| Validate JSON | Checks the result is valid JSON and fails if it is not. Off by default. |
Output
The Cleaned JSON String output is the fixed text.
Example
A model extracts each invoice’s number, date and amount in JSON, but sometimes adds a sentence before it.
- Connect the model’s answer to JSON String and turn on Validate JSON.
- Connect Cleaned JSON String to the component that stores the data.
Related components
- Create Data: creates data records.