Overview
This node converts data between JSON format and TOON format. It supports two modes: encoding JSON data into TOON format and decoding TOON format back into JSON. This is useful for scenarios where data needs to be compactly represented or transmitted in TOON format and later restored to JSON for processing or analysis. For example, encoding a JSON object to TOON for efficient storage or decoding TOON data received from an external source back to JSON for further use.
Use Case Examples
- Encoding JSON data to TOON format for compact transmission.
- Decoding TOON data back to JSON for data processing.
Properties
| Name | Meaning |
|---|---|
| Mode | Selects whether to encode JSON to TOON or decode TOON to JSON. |
| Input Data (JSON) | The JSON data to be encoded into TOON format. Used only in encode mode. |
| TOON Input | The TOON formatted string to be decoded back into JSON. Used only in decode mode. |
| Delimiter | The delimiter character used in encoding TOON format. Options include comma, tab, or pipe. Used only in encode mode. |
| Show Token Stats | If enabled, shows statistics about token usage and savings during encoding. Used only in encode mode. |
Output
JSON
toon- The encoded TOON string output when encoding.json- The decoded JSON object output when decoding.jsonTokenEstimate- Estimated token count of the original JSON data when showing stats.toonTokenEstimate- Estimated token count of the TOON encoded data when showing stats.savingsPercent- Percentage of token savings achieved by encoding JSON to TOON.error- Error message if encoding or decoding fails.success- Boolean indicating success status; false if an error occurred.
Dependencies
- @toon-format/toon
Troubleshooting
- Ensure the input JSON is valid and properly formatted when encoding.
- Verify the TOON input string is correctly formatted when decoding.
- Check that the delimiter selected for encoding is one of the supported options: comma, tab, or pipe.
- If an error occurs, the output will contain an error message and success will be false, indicating what went wrong.
Links
- @toon-format/toon NPM Package - The external library used for encoding and decoding TOON format.