Search notes:

jq: length

length returns the number of Unicode codepoints of a string, the number of elements in an array or the number of key/value pairs in an object. length(null) returns 0.
Count the number of fruits:
$ echo '{
    "fruits"    : ["apple" , "banana"  , "cherry"],
    "vegetables": ["carrot", "broccoli", "spinach", "couliflower"]
}' | jq '.fruits | length'
3
Count the number of letters in the second vegetable:
$ echo '{
    "fruits"    : ["apple" , "banana"  , "cherry"],
    "vegetables": ["carrot", "broccoli", "spinach", "couliflower"]
}' | jq '.fruits[1] | length'
6
Count the number of keys in the object:
$ echo '{
    "fruits"    : ["apple" , "banana"  , "cherry"],
    "vegetables": ["carrot", "broccoli", "spinach", "couliflower"]
}' | jq length
2

Index