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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1738303814, '3.141.201.46', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/JavaScript/JSON/tools/jq/functions/length(55): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78