Hello everyone,
I wanted to share a solution for a tricky issue I encountered while working with an API, in case it helps others.
1. The Challenge
When setting up connector outputs for an API call, I had issues processing a response where the keys contained special characters (e.g., ia::result
).
Standard extraction methods failed at the top level:
- Dot notation (
ia::result.0.id
) was ineffective. - Bracket notation (
['ia::result']
) also did not work in this context.
Despite many attempts with variations of these methods, I could not find a way to extract data using the ia::result
key directly.
2. The Solution: Deep Query Notation
The breakthrough came from using the deep query notation [**]
on the response body
.
Reference: json-query Deep Queries
This operator is typically used to perform a recursive search to filter complex, nested data structures. However, in this case, we are using it without any filter arguments. This causes the operator to simply find all values within the object and flatten them into a single list, effectively extracting the values of all top-level keys.
How to Implement It:
- Create an output for your connector function (e.g., a “List of Objects”).
- Set the JSON Extractor to
[**]
. - Apply this extractor to the
body
of the response.
This method effectively bypasses the parsing issues caused by the special characters.
3. Example Data Structure
To make it clear, here is a simplified example of the data before and after applying the extractor.
Before (Raw API Response body
)
{
"ia::result": [
{ "id": "1", "customer.name": "Reasonable Security" },
{ "id": "2", "customer.name": "Virginia Security" }
],
"ia::meta": {
"totalCount": 2
}
}
After (Result of [**]
Extractor) This creates a flattened list of the values from the top-level keys above.
[
{ "id": "1", "customer.name": "Reasonable Security" },
{ "id": "2", "customer.name": "Virginia Security" },
{ "totalCount": 2 }
]
Important Note on the Output: As you can see, this technique flattens the entire first level of the JSON. It creates a list containing all the objects from ia::result
but also includes the metadata object from ia::meta
as the last item in the list.
The main advantage is that you now have a list of objects without special characters. From this list, you can add further outputs to extract individual fields. For example, you can now use standard keys like id
and [customer.name]
to pull specific data points.
Hope this helps someone else out!