

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
In this cheat sheet you find Types and Values of JQ
Typology: Cheat Sheet
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Basic filters
. IDentity . foo . foo? Value of " foo " key .[]. []? Array iterator. Produce each element of an input array, or each value of an object .[ n ] n element of an array ( n can be negative : -1 -> last element...) . [ n : m ] Array slice : array containing n (inclusive) to m (exclusive) elements A , B Produces output of filter A then B (both A and B are fed with the same input) A | B Output of A is sent to B 's input ( A ) Grouping operator Types and Values [ ], { } Array (resp. Object) construction .. Recursive descent
SQL-Style Operators INDEX JOIN IN String manipulation tostring JSON-encode input as a string "( foo )" Interpolates foo inside a string index( foo ), rindex( foo ) Outputs the index of the first (index) or last (rindex) occurrence of foo in the input. startswith ( str ) Outputs true if. starts with the given string argument. endswith( str ) Outputs true if. ends with the given string argument. ltrimstr( foo ), rtrimstr( foo ) Outputs its input with the given prefix (resp. suffix) string removed, if it starts (resp. ends) with it. explode Converts an input string into an array of the stringโs codepoint numbers. implode The inverse of explode. split( foo ) Splits an input string on the separator argument. join( foo ) Joins the array of elements given as input, using the argument as separator. ascii_dow ncase, ascii_upc ase Emit a copy of the input string with its alphabetic characters (a-z and A-Z) converted to the specified case. Path & object manipulation path ( x ) Output the array representation of x : (keys/ indices, values) getpath( PATHS ) Outputs the values in_._ found at each path in PATHS setpath( PATH ; VALUE ) Set the PATHS in_._ to VALUE delpaths( PATHS ) Removes the key at the paths in PATHS to_entries Converts from object to an array of "key":"value" from_entri es Converts from an array of "key":"value" to an object with_entri es( foo ) Shortcut for to_entries | map( foo ) | from_entries flatten, flatten( depth ) Produces a flat array in which all arrays inside the original array have been recursively replaced by their values. Loop control while(co nd; update) repeatedly apply an update to. until cond is false. until(con d; next) repeatedly apply the expression next, initially to. then to its own output, until cond is true. recurse( foo [ , cond ] ) search through a recursive structure, and extract data from all levels. walk( foo ) applies foo recursively to every component of the input entity. bsearch( foo ) conducts a binary search for foo in the input array. Regular expressions test( RE [; FLAGS ] ) True if input string matches the given RE match( RE [; FLAGS ] ) outputs an object for each match it finds. capture( RE [; FLAGS ] ) Collects the named captures in a JSON object, with the name of each capture as the key, and the matched string as the corresponding value. scan( RE [; FLAGS ] ) Emit a stream of the non- overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified. split|splits ( RE [; FLAGS ] ), splits() Splits an input string, and provides an array (resp. stream) sub|gsub( RE ; tostring [; FLAGS ]) Emit the string obtained by replacing the first (resp. all) match of regex in the input string with tostring, after interpolation. FLAGS is any of "g, i, m, s, p, n, l, x" By Orabig cheatography.com/orabig/ Published 5th March, 2018. Last updated 5th March, 2018. Page 2 of 2. Sponsored by CrosswordCheats.com Learn to solve cryptic crosswords! http://crosswordcheats.com