<@U04S8PLJWMT> I'm having trouble configuring the ...
# ask-ai
b
@kapa.ai I'm having trouble configuring the Record Selector for a nested JSON response structure. My API returns data in the following format: json [ { "result": [ { "results": [ { "id": 2, "visitor_id": "kjhkjhjkhjkhjk", "url": "http://localhost:3001/", ... }, { "id": 3, "visitor_id": "kjhkjhjkhjkhjk", ... } ], "success": true, "meta": {...} } ], "success": true } ] I want to extract only the array inside results (the actual records). I've tried various Field Path configurations but none work: result[0].results [0].result[0].results 0.result.0.results result.0.results result.*.results What is the correct Field Path syntax to access the nested results array in this structure? Also, is there documentation on the supported JSONPath syntax for Record Selectors?
k
To extract the innermost array of records from your nested JSON structure using Airbyte's Record Selector, you should use the Field Path feature with the following configuration:
Copy code
yaml field_path: ["*", "result", "*", "results"]
Explanation: - The first
*
iterates over the root array. -
"result"
accesses the key in each object. - The next
*
iterates over the array under
"result"
. -
"results"
accesses the key containing your target records array. This will select all
results
arrays nested as described in your example, regardless of the array indices. Documentation Reference: - The
*
wildcard is used to iterate over arrays at any level in the path. This is documented in the [Record Selector documentation](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector) and the [DpathExtractor reference](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/DpathExtractor). - Airbyte uses a dpath-like syntax, not full JSONPath. The documentation provides several examples of how to use
*
for nested arrays and how to specify field paths for deeply nested structures. See the "Fields nested in arrays" example for a similar use case [here](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#field-path). Example from docs:
Copy code
yaml field_path: ["data", "*", "record"]
This pattern is analogous to your case, just with different field names. Note: If you want to extract the records themselves (the objects inside the innermost
results
array), you may need to set the field path to:
Copy code
yaml field_path: ["*", "result", "*", "results", "*"]
The final
*
will iterate over each object in the
results
array, returning each as a record. Summary: Use
["*", "result", "*", "results", "*"]
as your field path to extract each record object from your nested JSON response. For more details and examples, see the official documentation on [Field Path](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#field-path) and [Record Selector](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector).
b
@kapa.ai When i try this i get an error:
Copy code
Something went wrong in the connector. See the logs for more details.
dictionary update sequence element #0 has length 8; 2 is required
k
A message from kapa.ai
The error message you’re seeing—`dictionary update sequence element #0 has length 8; 2 is required`—typically indicates that the extractor is returning a list of lists (or a list of arrays), rather than a list of objects (dictionaries). Airbyte expects each record to be a dictionary/object, not an array. Based on the documentation, when using a field path like:
Copy code
yaml field_path: ["*", "result", "*", "results"]
this will select each
results
array, but not the individual objects inside those arrays. As a result, Airbyte receives a list of arrays, not a list of records, which causes the error. **To fix this, you need to add an additional
*
at the end of your field path to flatten the innermost array:**
Copy code
yaml field_path: ["*", "result", "*", "results", "*"]
This will extract each object inside every
results
array as an individual record, which matches Airbyte’s expectations. This approach is documented in the [Field Path section](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#field-path) and the [Record Selector YAML reference](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector). Summary of the solution: - Use
["*", "result", "*", "results", "*"]
as your field path. - This ensures that each record is a dictionary/object, not an array, resolving the error. If you continue to see issues, double-check that your JSON structure matches the example and that there are no unexpected types at any level of the path. For more details and examples, see the [official documentation](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#field-path).