...
An array selection combines field selection with indexing. For example content[0]
requires the current JSON object to have a field content
associated with an array, (e.g. {"content":[<values>...]}
) and tries to extract the element of the array at index 0
.
Example
Assume the AI provider returns the following JSON document (this example comes from Claude.ai):
Code Block | ||
---|---|---|
| ||
{
"content": [
{
"text": "Hi! My name is Claude.",
"type": "text"
}
],
"id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",
"model": "claude-3-5-sonnet-20241022",
"role": "assistant",
"stop_reason": "end_turn",
"stop_sequence": null,
"type": "message",
"usage": {
"input_tokens": 2095,
"output_tokens": 503
}
} |
To extract the useful response message - you would use the JQL query content[0].text
, which selects and extracts text from the string "Hi! My name is Claude."
. Similarly, the query model
would select the value of the "model"
field and extract the text from the string "claude-3-5-sonnet-20241022"
.