Avoid Spaces in JSON Keys to Prevent Zenphi Flow Errors
When working with JSON data in Zenphi—such as with HTTP actions, Gemini, or OpenAI—you might run into errors if your JSON keys contain spaces. Understanding this can help you avoid common flow issues.
What is a JSON Key?
A key is the name used to identify each piece of data in JSON. Think of it like a label for each value. For example:
{ "UnitPrice": 40.00 }
Here, "UnitPrice" is the key, and 40.00 is its value.
Titles vs Keys in JSON Schema
In a JSON schema:
Keys are the actual names used in the JSON data and should never contain spaces.
Titles are descriptive labels used inside the schema to explain what each key means. Titles can include spaces. For example:
"UnitPrice": {
"type": "string",
"title": "Unit Price"
}
The key is "UnitPrice" (no space), while the title is "Unit Price" (with space) for clarity.
Why Does This Matter?
Zenphi can successfully convert JSON with spaces in keys into objects using the "Convert JSON to Object" action. However, using those objects with spaced keys in other actions or external services sometimes causes errors, because spaces in keys are not universally supported and can be interpreted differently.
For example, this JSON will cause problems downstream:
{ "Unit Price": 40.00 }
How to Fix This
Always use keys without spaces in your JSON. Good examples:
UnitPrice
unit_price
unitPrice
Helpful Tip About Schema Inference
Zenphi can automatically infer a JSON schema from sample JSON you provide in the Convert JSON to Object action. But if the input JSON keys have spaces, it may cause errors in later steps, so it’s best to avoid spaces in the keys.
Gemini and OpenAI Actions
When using Gemini or OpenAI with JSON output enabled, make sure to:
Provide example inputs
Use keys without spaces in your JSON output
This helps Zenphi process the data correctly and avoids flow errors.
By keeping JSON keys free of spaces, you help ensure your Zenphi flows run smoothly and prevent common parsing issues.