Return the input unchanged
The identity filter is the smallest useful jq program.
.Input and expected output
{"hello":"world"}{
"hello": "world"
}jq cheatsheet
Identity, navigation, iteration, and composition. Explore 10 examples, then try one against the included input or your own data.
The identity filter is the smallest useful jq program.
.{"hello":"world"}{
"hello": "world"
}Chain object identifiers to walk through nested objects.
.user.profile.name{"user":{"profile":{"name":"Ada"}}}"Ada"Use bracket notation when a key is not a valid jq identifier.
.["first-name"]{"first-name":"Ada"}"Ada"The optional operator suppresses an error when the input cannot be indexed.
.users[] | .profile?.email?{"users":[{"profile":{"email":"a@example.test"}},null]}"a@example.test"
nullA missing object field normally yields null; ? is most useful when the input type may differ.
.[] is a generator: one input can produce many output values.
.users[]{"users":["Ada","Grace","Linus"]}"Ada"
"Grace"
"Linus"Array indexes are zero-based; negative indexes count from the end.
.users[-1]{"users":["Ada","Grace","Linus"]}"Linus"A slice includes the start index and excludes the end index.
.[1:4][0,1,2,3,4][
1,
2,
3
]The right side runs once for every value emitted on the left.
.users[] | .name{"users":[{"name":"Ada"},{"name":"Grace"}]}"Ada"
"Grace"The comma operator sends both filters the same input.
.id, .name{"id":42,"name":"Ada"}42
"Ada"Array construction collects all emitted values into one array.
[.users[].name]{"users":[{"name":"Ada"},{"name":"Grace"}]}[
"Ada",
"Grace"
]