Skip to content

Instantly share code, notes, and snippets.

@nikolay-n
Created September 29, 2020 20:49
Show Gist options
  • Save nikolay-n/a76d8dc3c32a70e53363d2429966816e to your computer and use it in GitHub Desktop.
Save nikolay-n/a76d8dc3c32a70e53363d2429966816e to your computer and use it in GitHub Desktop.
jqPlay snippets collected using google and github search

jqPlay snippets collected using google and github

  1. https://jqplay.org/s/8Zrwy7dDxW
map(select(.|length > 9))

  1. https://jqplay.org/s/Jb_fnBveMQ
with_entries(.value |= .ip)

  1. https://jqplay.org/s/O76mi-VYRs
del(.. | .pages?)

  1. https://jqplay.org/s/dx5rA2kfbg
if .[].username == "root" then .[].password else "" end

  1. https://jqplay.org/s/seNL7hW38W
.[1]

  1. https://jqplay.org/s/JJ2fqpEHib
.requestReports | reduce .[] as $item (0; . + ($item.total|tonumber))

  1. https://jqplay.org/s/lkXItbZCHZ
.dictionary | map(select (.examples | length > 0))

  1. https://jqplay.org/s/-UgbEC4BN8
fromstream([ [ "foo", "a" ], 1 ],[ [ "foo", "b" ], 2 ],[ [ "foo", "b" ] ],[["foo"]],[ [ "bar", "a" ], 1 ],[ [ "bar", "b" ], 2 ],[ [ "bar", "b" ] ],[ [ "bar" ] ]) | with_entries(.value += {key}) | .[]

  1. https://jqplay.org/s/k90JFcDqPz
"hi \(.name)"

  1. https://jqplay.org/s/JGIX6hTt_8
[.[]]

  1. https://jqplay.org/s/tblW7UX0Si
.subs[] | select(.name = "aaa") | .subs[] | select(.name = "bbb") | .subs[] | select(.name = "ccc") | .subs[] | .payload

  1. https://jqplay.org/s/u3_pDNyYfD
map(.CreatedOn)

  1. https://jqplay.org/s/Y9UgK_4xxE
.[]

  1. https://jqplay.org/s/A-coPyznVo
.list[] | {a, e} | select(.a == "b")

  1. https://jqplay.org/s/B677bZSVWa
.results[] | select( .types[] | contains("restaurant") ) | select( .opening_hours.open_now )

  1. https://jqplay.org/s/6HRvEND8AB
.[]

  1. https://jqplay.org/s/5BJsU3pyPM
del(.. | .publicAccess?, .userGroupAccesses?)

  1. https://jqplay.org/s/Eo6h_3V8PO
reduce (tostream|select(length==2)) as $i ({}; .[[$i[0][]|tostring]|join("_")] = $i[1] )

  1. https://jqplay.org/s/_5KiPRS75r
keys

  1. https://jqplay.org/s/risDCfxm5j
. | ( ("secrets","toto","test") as $k | (if index($k) | not  then  (. + {"$k":$k} ) else empty  end))

  1. https://jqplay.org/s/jFY3N2vXJ3
.

  1. https://jqplay.org/s/qqbHfBT0h5
"2019-05-23T02:00:06Z" as $arg | map(select(.time < $arg)) | max_by(.time)

  1. https://jqplay.org/s/9TqdXbe0lo
.|length

  1. https://jqplay.org/s/Z5qjhJnRyn
.[].name

  1. https://jqplay.org/s/L5bu1ovLr-
.|.url

  1. https://jqplay.org/s/BjgdGsjPem
map(length)

  1. https://jqplay.org/s/Tn7NUbP4Dr
.url

  1. https://jqplay.org/s/LYflwM4kJM
[.name, .url]

  1. https://jqplay.org/s/y8WwvHISH4
map(if . == 0 then "zero" elif . == 1 then "one" elif . == 2 then "two" else "many" end)

  1. https://jqplay.org/s/KhRuUFCP2h
.

  1. https://jqplay.org/s/ae0RTNbTiY
sort_by(.name)

  1. https://jqplay.org/s/ufUZAtLeHn
[contains("x"), contains("x\u0000"), contains("x\u0000y"), contains("y")]

  1. https://jqplay.org/s/HRWV44YgUp
[ .[] | select (.values.timestamp?) ]

  1. https://jqplay.org/s/ncoCnMU6WW
.groups | to_entries | map( {(.value[]): {(.key):null} }) | reduce .[] as $item ({}; . * $item) | to_entries | map({key:.key, value:(.value|keys)}) | from_entries

  1. https://jqplay.org/s/02CPHO1ESj
.url, .name

  1. https://jqplay.org/s/uHqfdPoF3e
[ to_entries[] | .value = .value.value ] | from_entries

  1. https://jqplay.org/s/zkBQG8vTN8
.html.body.li[]."$t"

  1. https://jqplay.org/s/1m7wAeHMTu
def walk(f): . as $in | if type == "object" then   reduce keys[] as $key    ( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f elif type == "array" then map( walk(f) ) | f else f end; walk(if (type == "object" and .publicAccess) then del(.publicAccess) elif (type == "array" and .userGroupAccesses) then del(.userGroupAccesses) else . end )

  1. https://jqplay.org/s/RbKiioures
[.[] | select(.key3 == true) |= {"key1": ("updated_" + .key1), "key2": (.key2 * 2), "key2a": ("updated_" + (.key2|tostring)), "key3": .key3}]

  1. https://jqplay.org/s/3VpRc5l4_m
map_values(     reduce group_by(.role)[] as $g ({};         .[$g[0].role].hosts = [$g[] | del(.hostname, .role)[]]     ) )

  1. https://jqplay.org/s/2mY6yus7Mz
map ( with_entries(select(.key != "fields")) + (.fields | with_entries(.value = (.value| join(",")))) )

  1. https://jqplay.org/s/plpHDzbjnW
# Apply f to composite entities recursively, and to atoms def walk(f):   . as $in   | if type == "object" then       reduce keys[] as $key         ( {}; . + { ($key):  ($in[$key] | walk(f)) } ) | f   elif type == "array" then map( walk(f) ) | f   else f   end;  def normalize: walk(if type == "array" then sort_by(.name) else . end);  normalize

  1. https://jqplay.org/s/AVpz_IkfJa
.content.data  | del( 	.hits[].doc.notes[]  	| select 		( .types  		| any(startswith("x") or startswith("y"))  		| not  		) 	)

  1. https://jqplay.org/s/G7GxNYYqY1
if .[].username == "root" then .[].password else "" fi

  1. https://jqplay.org/s/N9b0fanbyh
{DesktopEntry: .} | .DesktopEntry |= split("\n") | .[]  |= reduce (.[] | split("=")) as [$key, $value] ({}; .[$key] = $value)

  1. https://jqplay.org/s/nwxNZ7LOY6
del(.pages)

  1. https://jqplay.org/s/5Uc6-Lkxpv
reduce (.items[] | select(.charge == null)) as $i (0;.+=1)

  1. https://jqplay.org/s/L-Rnd1C6yv
.items[] | select(.charge == null) | .id

  1. https://jqplay.org/s/qpx5knqiPt
def walk(f): . as $in | if type == "object" then   reduce keys[] as $key    ( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f elif type == "array" then map( walk(f) ) | f else f end; walk(if type == "object" then del(.publicAccess, .userGroupAccesses) else . end)

  1. https://jqplay.org/s/X5MI2D4YrH
. + {two:"newtwo", three:"newthree"}

  1. https://jqplay.org/s/srPWnELEiS
.[] | "curl -s -o output/\(.name)\(.extension) \(.url)"

  1. https://jqplay.org/s/mwBhsYud2F
map(select(.letters//[]|((contains(["a"]) or contains(["b"])) and (contains(["a", "b"])|not))))

  1. https://jqplay.org/s/phmy8taWCu
"youtube.com/watch?v=\(.videos[].video_id)"

  1. https://jqplay.org/s/WaQEdx99mp
.data | map({id: .id, q: .pages[].questions[]}) | map({id: .id, q: .q.heading, a: .q.answers[0].simple_text})

  1. https://jqplay.org/s/Bi3FbRMi7_
.[0].windows[]? | map(.url)? | sort

  1. https://jqplay.org/s/DqbLesXlCP
.

  1. https://jqplay.org/s/xLb30v0X5T
.[].info[] |= {(.key):.value, (.keyCaption):.valueCaption}

  1. https://jqplay.org/s/LRHW9BaX42
[.mine[] as $in | .stuff[$in].name]

  1. https://jqplay.org/s/FPBiC8xt3p
group_by(.org, .rc."$event")[] | [.[0].rc."$event", .[0].org, length] | @tsv

  1. https://jqplay.org/s/0aVbFzMttK
.+{"headers": {}} and .shoporders[] + {"ext_ad_info_mappings": []} and .payment_channel_info.grouping_info.groups[].display_info + {"enabled": true}

  1. https://jqplay.org/s/2uk_Z_sjug
.[0].timestamp

  1. https://jqplay.org/s/QJz5FCmuc9
.[] | [.time, .descendantcount, .ancestorcount] | @csv

  1. https://jqplay.org/s/XfDUheaXFB
.items[]  | select(.name == "thing-3") | .

  1. https://jqplay.org/s/ugF5foO90N
.headers = {} | .shoporders[].ext_ad_info_mappings = [] | .payment_channel_info.grouping_info.groups[].display_info.enabled = true

  1. https://jqplay.org/s/cLAeCsoIY9
getpath( paths(has("class")?) ) | [.class,.score] | @csv

  1. https://jqplay.org/s/3WctRQDHhg
.

  1. https://jqplay.org/s/vilCNy-iTD
.hits.hits[] |= {id}

  1. https://jqplay.org/s/aWWN_xVzpD
(.TagSet[] | select(.Key=="key1")).Value = "foo"

  1. https://jqplay.org/s/33L3zA9Fos
.service |= [., .name = "tomcat"]

  1. https://jqplay.org/s/RTepHq7GC-
.foo

  1. https://jqplay.org/s/kF2SWNRv84
.[] | select(.id == "3" or .id == "2") | .name,.value

  1. https://jqplay.org/s/k747PBLh4T
reduce .[] as $s(0; if $s.spam_score > 40 then .+1 else . end)

  1. https://jqplay.org/s/tSkYQN5xF-
path(.cells[] | select(.foo[0] == "# BAR\n"))

  1. https://jqplay.org/s/-3HVKchyfi
with_entries(.value |= @sh) | to_entries[] | "\(.key)=\(.value)"

  1. https://jqplay.org/s/8bNKn7d-fu
. | to_entries| .[].key

  1. https://jqplay.org/s/QzOttRHoz1
foreach .Names[] as $name ([];[];$name | [.Name, .Age])

  1. https://jqplay.org/s/M_RpdNHvHF
. |= try . catch .

  1. https://jqplay.org/s/9a_OBo6FlE
[leaf_paths as $path | {"key": $path | join("_"), "value": getpath($path)}] | from_entries

  1. https://jqplay.org/s/y6YWdlXfl8
setpath(path(.TagSet[] | select(.Key=="key1") | .Value); "foo")

  1. https://jqplay.org/s/mIRTvuLNDn
[ .links[] | select(.active == true) | { created: (.created|todate), title, url } ]

  1. https://jqplay.org/s/TNq7c5ctot
[.all_commit_details[].subject | scan("([A-Z]{2,30}-[0-9]+)")   | .[] ]

  1. https://jqplay.org/s/qVZKGt92FM
.[] | {age: .foo}

  1. https://jqplay.org/s/QA0f2qEE4S
.name as $p | .children[] | [$p, (recurse(.children[]) | .name)] | join("/")

  1. https://jqplay.org/s/ktL3ZhscMh
{ "foo" : .foo.bar, "sub": .foo.baz | tostring }

  1. https://jqplay.org/s/OHGD3RHk1f
match("(?<p>\\()?[^()]+(?(p)\\))?")

  1. https://jqplay.org/s/fOBuwdj6WS
if .[].name|type == "array" then .[].name[0]?  else first(.[].name) end

  1. https://jqplay.org/s/VctBNl2TYN
.properties|.maxTemperature.values[].value,.minTemperature.values[].value,.weather.values[].value[].weather

  1. https://jqplay.org/s/D5-FZl8wOs
to_entries[] | {hash: .key, val: .value[]} | [.hash, .val.i, .val.p, .val.l]

  1. https://jqplay.org/s/X9nYQDDGbG
{ "@name": .site."@name", "@ssl": .site."@ssl", "alerts": [.site.alerts[] as $in | $in.instances[] as $h |  $in | del(.instances) as $in2 |  $h * $in2 ]}

  1. https://jqplay.org/s/578mkUAklU
(.TaskGroups[] | select(.Name == ("test1", "test5")).Count) |= 0 | {Job : . }

  1. https://jqplay.org/s/ZIFU5gBnZ7
([.titles,.years]|transpose[]) as [$title,$year] | {user,$title,$year}

  1. https://jqplay.org/s/vQ1_Psl1LI
.[]|[.from?,.date,.text]|@csv

  1. https://jqplay.org/s/N-M-QiVCq4
.newList[] | "\(.id) \(.create.date)"

  1. https://jqplay.org/s/UwHkeiH9NG
[keys[] as $k | {($k):.[$k]} | tojson[1:-1]] | join(",")

  1. https://jqplay.org/s/ggmuK5WvZF
sub("b","f")

  1. https://jqplay.org/s/0hYw08MN1C
.links[0]

  1. https://jqplay.org/s/xGA99WWoKT
.builders += [.builders[0] | .name = "production"]

  1. https://jqplay.org/s/AhaMCazi9o
.links."urn:somedomainid:follow".href

  1. https://jqplay.org/s/LU5_ewGqga
[ .links[].url ]

  1. https://jqplay.org/s/nQubEJotBR
gsub("\n"; "<br />")

  1. https://jqplay.org/s/xClPHmIsTZ
[ to_entries[] | { "name": .key, "count": [ .value | to_entries[] | { "type": .key, "number": .value } ]}]

  1. https://jqplay.org/s/duCj0FrEAt
.|fromjson

  1. https://jqplay.org/s/CR8mGBX8Dz
[.root[] | {field1, field2, field3Array: .field3Array[].prop1}]

  1. https://jqplay.org/s/e8ZHP1t_K3
def pad(n):"\(.)"|(split(".")+["0"])[:2]|.[1]|=(.+"0"*n)[:n]| join("."); "\(.lat|pad(9)) \(.lon|pad(9))"

  1. https://jqplay.org/s/6bxD-Wq0QE
.data.search.edges[].node | {name, topics: ..|.topics? | map(select(. != null) | flatten}

  1. https://jqplay.org/s/YP1oGSTgge
.results[] | select( .types[] | contains("restaurant") ) | .name

  1. https://jqplay.org/s/gHGkdx8nJR
reduce leaf_paths as $p (.; if $p[-2]=="agents" and getpath($p)=="agent4" then delpaths([$p]) else . end)

  1. https://jqplay.org/s/LtXR8qfo6D
.prefixes[] | select(.region=="ap-northeast-1" or .region=="ap-northeast-3") | select(.service=="EC2") | .ip_prefix

  1. https://jqplay.org/s/CpDPlGueMM
[.[].assets | .[].download_count] | add

  1. https://jqplay.org/s/gwvMIH_fed
{"apiId": .value[].id, "metrics": .value[].name.value, "timestamp": .value[].timeseries[].data[].timeStamp, "value": .value[].timeseries[].data[].average}

  1. https://jqplay.org/s/KxQS_Rx0rL
{ retracted: (."update-to"[0].type == "retraction"), update: { timestamp: ."update-to"[0].updated.timestamp, doi: .DOI, type: ."update-to"[0].type }, doi: ."update-to"[0].DOI, journal: ."container-title"[0], publisher: .publisher, title: .title[0]  }

  1. https://jqplay.org/s/KzNXa7NqKq
. += [{"severity": "Severity","name": "Name","files": "Files","id": "0"}, {"severity": "--------","name": "------------------------------------","files": "--------","id": "01"}] |  sort_by(.id) | .[] | ["| " + .severity, "| " + .name, "| " + (.files | join (",")) , "| " ]

  1. https://jqplay.org/s/XjqqNuINeZ
map(sub("^\\d+";""))

  1. https://jqplay.org/s/ger1zb3_xV
transpose|map(add)

  1. https://jqplay.org/s/sxussfa2Vj
.objectEntries | {tickets: map(.attributes |  {ticketID: (reduce .[] as $r (null;  if $r.objectTypeAttributeId == 328 then $r.objectAttributeValues[0].value else . end)),date: (reduce .[] as $r (null;  if $r.objectTypeAttributeId == 330 then $r.objectAttributeValues[0].value else . end)), hostnames: (reduce .[] as $r ([];  if $r.objectTypeAttributeId == 329 then $r.objectAttributeValues | map(.value) else . end))})}

  1. https://jqplay.org/s/59vZhMXYbe
["\(1+range(5))"] as $units | ["Action", "Group", "Unit\($units[])"], (inputs | .Action as $a | (.Group // [{Id:"0", Units:[]}])[] | [$a, .Id, (.Units[$units[]|[.]] | if .!=[] then "1" else "0" end) ] ) | join("|")

  1. https://jqplay.org/s/_BAt2M6bkZ
.results[] | select( .types[] | contains("restaurant") )

  1. https://jqplay.org/s/GpVJfbTO-Q
. as $root | .source + { items: [.source.items[] | select(.id as $id | $root.update.toRemove | contains([$id]) | not)]}

  1. https://jqplay.org/s/itgHiQlNMP
.foo.["x"]

  1. https://jqplay.org/s/CzPU5im0RE
map(select(.finalStatus != null))

  1. https://jqplay.org/s/Od6lj5qjwm
[ ..|.types? | arrays ] | flatten | unique

  1. https://jqplay.org/s/xX_wUM-o5W
[ .links[] | select(.active == true) ]

  1. https://jqplay.org/s/izjjHkDpdG
.limit, .offset, (.values[] | .id, .type, .users.total, .users.profiles[].first_name, .users.profiles[].last_name)

  1. https://jqplay.org/s/onlU9ghjn1
.gcp_price_list | ."CP-COMPUTEENGINE-OS" |  (     if ( .[].cores == "shared" ) then         .[].cores = 0.5      else .[].cores = .[].cores end )

  1. https://jqplay.org/s/bgiJvPKryC
[.[] | {id: .identifier, title: .title, downloads: [.other_download[].access_url?][0], website: .website, description: .description.en, triples: .triples, domain: .domain?, example: .example[].access_url?, sparql: .sparql[].access_url?, namespace: .namespace?} ]

  1. https://jqplay.org/s/xjND6Iv60T
| unique | sort

  1. https://jqplay.org/s/7JSSbYF32N
sort_by(.timestamp) | map(select(.result.Code == 0)) | map(select(.tx.value.msg[0].value.dst_owner == "faa14sk203d2akh96gdlhveglw5emfpf0h8xqls3l0")) | .[].tx.value.msg[0].value.src_owner

  1. https://jqplay.org/s/x3IArefkyH
.orders[].items = 321

  1. https://jqplay.org/s/cgwBLk3dxa
[.result[].id]| unique | .[] | "* [[TreeNodeKind/" + . + "]]"

  1. https://jqplay.org/s/n7WjphEVf7
select(.some.more.depth=="here") | tee .version | .some.more.depth

  1. https://jqplay.org/s/yYrdjEEhIm
.[].urls[] | select(.url=="pixiv") json

  1. https://jqplay.org/s/aUTncmciuj
def row($i; $padding):   . as $in   | [range(0;$padding) | null] as $nulls   | reduce range(0; length) as $ix        ([]; . + ($in[$ix][1][$i] // $nulls));  | (map(.[1] | length) | max) as $rows | range(0; $rows) as $r | row($r; 4) | @tsv

  1. https://jqplay.org/s/npoAQkfK9V
.gcp_price_list| [.[keys[] | select(contains("VMIMAGE"))]]

  1. https://jqplay.org/s/svMcFCRZ31
.[] | select(.Names[] | contains("_db_")) | select(.State == "running") | .Status | contains("healthy")

  1. https://jqplay.org/s/QOs3d_fMLU
(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv

  1. https://jqplay.org/s/GgXZg67o79
{"id": .id, "name": .tags[]|select(.Key=="Name").Value}

  1. https://jqplay.org/s/1D40LxXtKF
.results[] | select( .types[] | contains("restaurant") ) | [.name, (.types | join(", "))?] | join(": ")

  1. https://jqplay.org/s/YqGkGYKaeI
capture("")

  1. https://jqplay.org/s/EH9aWjmNR4
now|todate,now,now|todate

  1. https://jqplay.org/s/0IfiBoskG5
reduce (.issues | to_entries[]) as {$key,$value} ({};     .["JIRA-\($key + 1)"] = $value.key )

  1. https://jqplay.org/s/VvdATQ6bAr
.cluster.collections | select (.myApp.shards.shard1.replicas[].node_name=="1.2.3.46:8983_emo")

  1. https://jqplay.org/s/_O6MtY3FlH
.[] | .id, .content, ""

  1. https://jqplay.org/s/CAMSFmpe3W
.items[] | .node + " " + .result.stdout

  1. https://jqplay.org/s/mrq5-WqKip
tostream | select(length==2) | .[0] |= map(strings) | flatten | join("/")

  1. https://jqplay.org/s/szc4FvPq7C
[.[]|{id:.children[0].text,cat1:.children[1].children[0].text,cat2:.children[1].children[2].text,titolo:.children[2].text,dataInizio:(.children[3].text|split(" "))[0]| strptime("%d/%m/%Y") | strftime("%a, %d %b %Y 02:00:00 +0200"),dataFine:(.children[3].text|split(" "))[1]| strptime("%d/%m/%Y") | strftime("%a, %d %b %Y 02:00:00 +0200")}]

  1. https://jqplay.org/s/6DsIxWBa1L
.[].[no]

  1. https://jqplay.org/s/QfPXOe20Ex
sort_by(.timestamp) | map(select(.result.Code == 0)) | map(select(.tx.value.msg[0].value.coins[0].denom != "iris-atto")) | .[].tx.value.msg[0].value.owner

  1. https://jqplay.org/s/GWn_IEuyAy
sort_by(.timestamp) | map(select(.result.Code == 0)) | .[].tx.value.msg[0].value.owner

  1. https://jqplay.org/s/BaI4jtzmUf
.payload | fromjson

  1. https://jqplay.org/s/-EfBYL8JPn
.policy.sites.trusted[] | sub("§:";"") | "* \(.) * noop"

  1. https://jqplay.org/s/9UcLXKEgaT
.tests |.[] |.foobar

  1. https://jqplay.org/s/sccwJi75jb
{name: .[1]}

  1. https://jqplay.org/s/s1GiNkp_Ed
{name, age: .ages[]}

  1. https://jqplay.org/s/1ckAfiLKA3
.|join(" | ")

  1. https://jqplay.org/s/_7uGMWvmUh
split(" | ")

  1. https://jqplay.org/s/mL-eA6ZJlI
map(select(.country=="Canada"))

  1. https://jqplay.org/s/zg_l3ZoT6C
.databases | map({db: .name, user: .users[].username})

  1. https://jqplay.org/s/eRBisoYbDb
.regions | [to_entries[] | {"key": .value.displayName, "value": .value.slug}]|from_entries

  1. https://jqplay.org/s/cFmrjydbkC
.regions | [to_entries[] | {"key": .value.displayName, "value": .value.slug}]|from_entries

  1. https://jqplay.org/s/8Hd1vD-PmF
[     .[][0] | select(.region != null) | {         "location": .location,         "region": .region     } ] | unique

  1. https://jqplay.org/s/dtvjDF6QKj
.gcp_price_list | . |=with_entries (      select(         .key | contains("INTERNET")       ) )

  1. https://jqplay.org/s/Gvh3qis9pj
.gcp_price_list | . |=with_entries (      select(         .key | contains("INTERNET")       ) )

  1. https://jqplay.org/s/1PlNwqyVhC
capture("\\\\(?<key>[a-z]+) (?<value>.*)")

  1. https://jqplay.org/s/eOI_lLytRP
.offers.transactions.prices

  1. https://jqplay.org/s/NbdTDztQbb
.offers | del( .transactions)

  1. https://jqplay.org/s/D3L0oGVSq3
keys

  1. https://jqplay.org/s/usBT4XfMaE
walk(if type == "string" then gsub("\\p{Cc}"; " ") else . end) |[.level,.content, .logger_name]

  1. https://jqplay.org/s/uqwmmsbkvi
[.level, (.content | gsub("[\\p{Cc}]"; " ")[0:20] ),.logger_name ]

  1. https://jqplay.org/s/tt302_aTzV
.gcp_price_list | . |=with_entries (      select(         .key |         contains("CP-COMPUTEENGIN") and (             contains("PD") or             contains("SSD")         )      ) ) |  [ to_entries[] |      {         "name": .key,         "prices":           [              .value | to_entries[] |             { "region": .key, "price": .value }          ]      }  ]

  1. https://jqplay.org/s/i8blbKEmeC
.gcp_price_list | . |=with_entries (      select(         .key |          contains("CP-COMPUTEENGIN") and (             contains("PD") or             contains("SSD")         ) and (contains("IO-REQUEST") | not)     ) ) |  [ to_entries[] |      {         "name": .key,         "prices":           [              .value | to_entries[] |             { "region": .key, "price": .value }          ]      }  ]

  1. https://jqplay.org/s/iy0C1YR1Hq
.gcp_price_list | . |=with_entries(select(.key| contains("VMIMAGE") )) |  [ to_entries[] |      {         "name": .key,         "cores":(             if (.key|contains("F1-MICRO")) then                 0.2              elif (.key|contains("G1-SMALL")) then                 0.5             else .value.cores end         ),         "memory": .value.memory,         "gceu": (             if .value.gceu == "Shared CPU, not guaranteed" then                 null             else .value.gceu end         ),         "maxNumberOfPd": .value.maxNumberOfPd,         "maxPdSize": .value.maxPdSize,         "price":           [              .value | del(                 .cores, .memory, .gceu,                 .fixed, .maxNumberOfPd, .maxPdSize, .ssd)             | to_entries[] | { "region": .key, "price": .value }          ]      }  ]

  1. https://jqplay.org/s/8bvhcfLZV4
.gcp_price_list | . |=with_entries(select(.key| contains("VMIMAGE") )) |  [ to_entries[] |      {         "name": .key,         "cores":(             if (.key|contains("F1-MICRO")) then                 0.2              elif (.key|contains("G1-SMALL")) then                 0.5             else .value.cores end         ),         "memory": .value.memory,         "gceu": (             if .value.gceu == "Shared CPU, not guaranteed" then                 null             else .value.gceu end         ),         "maxNumberOfPd": .value.maxNumberOfPd,         "maxPdSize": .value.maxPdSize,         "price":           [              .value | del(                 .cores, .memory, .gceu,                 .fixed, .maxNumberOfPd, .maxPdSize, .ssd)             | to_entries[] | { "region": .key, "price": .value }          ]      }  ]

  1. https://jqplay.org/s/Rog9ZugjW-
.[]|[.id, .name,.description,.namespace,.statistics.commit_count, .statistics.repository_size]

  1. https://jqplay.org/s/lOf6--Qfwu
.[]| [.id, .short_id]

  1. https://jqplay.org/s/IrbiQWTZbQ
def set(s): reduce s as $x ({}; .[$x | (type[0:1] + tostring)] = $x);  def distinct(s): set(s)[];  .gcp_price_list | del(.sustained_use_base,.sustained_use_tiers) | [      distinct(.[]            | keys_unsorted[] as $k            | select( getpath([$k]) | type == "number")            | $k) ] - ["maxNumberOfPd", "maxPdSize", "gceu"]

  1. https://jqplay.org/s/6TqXSWl_0w
def set(s): reduce s as $x ({}; .[$x | (type[0:1] + tostring)] = $x);  def distinct(s): set(s)[];  .gcp_price_list | del(.sustained_use_base,.sustained_use_tiers) | [      distinct(.[]            | keys_unsorted[] as $k            | select( getpath([$k]) | type == "number")            | $k) ] - ["maxNumberOfPd", "maxPdSize", "gceu"]

  1. https://jqplay.org/s/yP8J1oVhfs
.gcp_price_list.NETWORK_LOAD_BALANCED_INGRESS

  1. https://jqplay.org/s/_hy6zyaSBd
.gcp_price_list.NETWORK_LOAD_BALANCED_INGRESS

  1. https://jqplay.org/s/1Ugkd8zB3B
.gcp_price_list | . |=with_entries (      select(         .key | contains("RULE")        ) )

  1. https://jqplay.org/s/95EyhhroA9
.gcp_price_list | . |=with_entries (      select(         .key | contains("RULE")        ) )

  1. https://jqplay.org/s/M5Ky1KJd-C
.store.book[] | select(.category=="reference") |.author

  1. https://jqplay.org/s/rDPhRVFSsj
.[] |[.id, .short_id,.parent_ids,.title,.message]

  1. https://jqplay.org/s/dWeikiBJKj
capture("^#{2,} (?<value>[A-Z]+): ")

  1. https://jqplay.org/s/hGLDkMm3-M
.results[] | select( .types[] | contains("restaurant") ) | select( .opening_hours.open_now ) | .name

  1. https://jqplay.org/s/OrtlyrkIyg
.[] | .["a"]

  1. https://jqplay.org/s/DljtxNX_72
select((.properties.id | tonumber) != .properties.recipient.id)

  1. https://jqplay.org/s/4GNwRCpQLX
foreach .[] as $item (0; . + 1; "\(.) - \($item)")

  1. https://jqplay.org/s/LY8so0wxbk
.selectedUser+={"profile" : "aabc1f631b274fea85fabec6c3487ee1"}

  1. https://jqplay.org/s/tnH4k6BS6i
.. | select(.focus?) as $root |  ..| select(.focused?) | "\(.name) \($root.layout)"

  1. https://jqplay.org/s/BusOB8PMQ2
[.result[].id]| unique | .[] | "* [[TreeDumpIndex/" + . + "]]"

  1. https://jqplay.org/s/itc9Xo1HIt
[.result[].id]| unique | .[] | "* [[TreeCodeClass/" + . + "]]"

  1. https://jqplay.org/s/1nkuX_LRiU
[.result[].id]| unique | .[] | "* [[TreeCodeClass/" + . + "]]"

  1. https://jqplay.org/s/f8Ij7g73IG
[.result[].id]| unique | .[] | "* [[TreeCodeClass/" + . + "]]"

  1. https://jqplay.org/s/2sm1pKQ2fS
first(select(.updated_at=="2019-06-03T16:36:53.194Z"))

  1. https://jqplay.org/s/DeSANQZtj7
nth(1; select(.updated_at=="2019-06-03T16:36:53.194Z"))

  1. https://jqplay.org/s/nYlPohfTdZ
.response.data.sessions[0].user

  1. https://jqplay.org/s/Cw-nbWwmjz
select(.requested_reviewers | length > 0)

  1. https://jqplay.org/s/n5jsRsPMhW
[ .[] | select (.values | has("timestamp")?) ]

  1. https://jqplay.org/s/KLPXwB7Ey_
.[].item1 as $item | $item.array1[] | $item.item2 , .item3 , .item4

  1. https://jqplay.org/s/g_8HgqiQ1o
[inputs.host/"-"|last]|group_by(.)[]|"\(.[0]) -> \(length)"

  1. https://jqplay.org/s/S2oeLfMRNR
reduce (inputs.host/"-"|last) as $k ({}; .[$k] += 1)|to_entries[]|"\(.key) -> \(.value)"

  1. https://jqplay.org/s/ypiYcNBa-I
.endpoints |= map((.virtual_endpoint | sub("https?://[^/]+"; "")) as $end_p  | .vs_endpoints |= [.[] | . + $end_p] )

  1. https://jqplay.org/s/xjMiqANQ3p
.versions[].columns |= map(if(.type == "varchar" and .length < 255) then .length = 255 else . end)

  1. https://jqplay.org/s/zL6HpSSFw0
.[] | [.urlString, .imageUrl] | @csv

  1. https://jqplay.org/s/6zMyKjTehN
map(select(.product.type == "mobile")) | .[] | {id: .product.id, service: .product.service}

  1. https://jqplay.org/s/_0CFADWu2G
.remote | group_by(.name) | map({ (.[0].name): map(.id) }) | add

  1. https://jqplay.org/s/OTbaGREIUH
to_entries | sort_by(.value) | reverse | from_entries

  1. https://jqplay.org/s/Q81EZahkjG
foreach tostream as $pv ([[],[]]; if ($pv|length) == 2 then (.[0] |= if . == [] then . + [$pv[0][0],$pv[1]] else . + [$pv[1]] end) else [[],.[0]] end; if .[0] == [] and .[1] != [] then .[1] else empty end)

  1. https://jqplay.org/s/VeGHuouLRY
.[] as $x | { price: ($x.price * -1) }

  1. https://jqplay.org/s/y6AFKg2dSM
reduce (.issues | to_entries[]) as {$key,$value} ({};     .["JIRA-\($key + 1)"] = $value.key )

  1. https://jqplay.org/s/H2uxyFJn9E
.issues | with_entries({key: "JIRA-\(.key + 1)", value: .value.key})

  1. https://jqplay.org/s/Xp64LfJFBc
..|.foo?

  1. https://jqplay.org/s/ZGj1wC8hU3
reduce ([inputs[][]] | group_by(.role)[]) as $g ({};     .[$g[0].role].hosts = ([$g[] | del(.hostname, .role)[]] | unique) )

  1. https://jqplay.org/s/-sZ7tvU4Yb
.datasets[].features[].stringStats // empty

  1. https://jqplay.org/s/54OH83qHKP
.data.result[] | if .metric.pod | contains("dev-cds") then . else empty end

  1. https://jqplay.org/s/fwjTN1CnFc
{a: .a},  (.list | map({(.Key): .Value}) | add)

  1. https://jqplay.org/s/n1kf-19yFT
.data.devices | to_entries | map({key, value: {ip: .value.ip, otherInformation: .value.otherInformation}}) | from_entries

  1. https://jqplay.org/s/zLsEYAQrFC
(.microservices[] | select(.appId == "builds")).volumesFrom = ["foo","bar"]

  1. https://jqplay.org/s/de4X1TUBG4
.rows[].Egroup|join(",")

  1. https://jqplay.org/s/iaSIPnkxFm
.[].Checks[1].ServiceTags

  1. https://jqplay.org/s/ea-LyKhhpy
.[].Checks[1].Node

  1. https://jqplay.org/s/NAhuXNYXXO
. as $original | .[] | select(.Id == "ghi") | [.Dependencies[]] as $level1Dep | [$original[] | select( [ .Id == $level1Dep[] ] | any )] as $level1Full | $level1Full[] | [.Dependencies[]] as $level2Dep | [$original[] | select ( [ .Id == $level2Dep[] ] | any )] as $level2Full | [$level1Dep[], $level2Dep[]]

  1. https://jqplay.org/s/Zs0xIvJ2Zn
. as $original | .[] | select(.Id == "jkl") | [.Dependencies[]] as $level1Dep | [$original[] | select( [ .Id == $level1Dep[] ] | any )] as $level1Full | $level1Full[] | [.Dependencies[]] as $level2Dep | [$original[] | select ( [ .Id == $level2Dep[] ] | any )] as $level2Full | [$level1Dep[], $level2Dep[]]

  1. https://jqplay.org/s/eB9zHQSH2r
. as $original | .[] | select(.Id == "ghi") | [.Dependencies[]] as $level1Dep | [$original[] | select( [ .Id == $level1Dep[] ] | any )] as $level1Full | $level1Full[] | [.Dependencies[]] as $level2Dep | [$original[] | select ( [ .Id == $level2Dep[] ] | any )] as $level2Full | [$level1Dep[], $level2Dep[]]

  1. https://jqplay.org/s/k-ZylbOC6W
{temp:.temperature,hum:.humidity, id: (.message | capture("ID (?<id>[[:digit:]]+)").id)}

  1. https://jqplay.org/s/5TlSDgJnkc
[.rows[]]

  1. https://jqplay.org/s/B-JW8wnqG3
del( .a[].c[] | select(has("e")))

  1. https://jqplay.org/s/-YDVDeXTHb
.gcp_price_list | del(.sustained_use_base,.sustained_use_tiers) | .[] | keys[]

  1. https://jqplay.org/s/xHWg8aGSSS
[(..|objects.locator|strings), (..|select(objects."#name" == "section-title")._)] | @tsv

  1. https://jqplay.org/s/N6TboUkELM
.example."sub-example"|map(.name)

  1. https://jqplay.org/s/G2inYAJNLS
[.data.search.edges[].node | {name,topic:(.repositoryTopics.nodes[].topic.topics)}]

  1. https://jqplay.org/s/0AFneNK89i
[.data.search.edges[].node | {name,topic:[.repositoryTopics.nodes[].topic.topics]}]

  1. https://jqplay.org/s/b7ByAsQ571
.[] + {name:.|keys[]}

  1. https://jqplay.org/s/MiJ9w1Sz5L
.desc | . as $in| keys[]

  1. https://jqplay.org/s/DRkQwRC9Rx
reduce (paths(numbers) as $p | [$p[1:], getpath($p)]) as $i ({}; setpath($i[0]; getpath($i[0]) + $i[1]))

  1. https://jqplay.org/s/YPG4I9BMDn
[.items[] ] [] | [.id, .name]  | .[0]

  1. https://jqplay.org/s/cEzh5_LimP
._embedded.items | map({(.order| tostring ) : .technical._links.self.href} )

  1. https://jqplay.org/s/YvpCb2PH42
keys

  1. https://jqplay.org/s/fDzVed_Isv
.a[] | .c[] | if .e then del(.) else . end

  1. https://jqplay.org/s/0-o4HOox-K
.assetbase[].assetbase[].items

  1. https://jqplay.org/s/_6KVDfIn3m
.platform.target_id as $target | .profiles[].controls[] | { Host: $target,   Title: .title,   Status: .results[].status }

  1. https://jqplay.org/s/S65ySzbF30
(now | todate) as $_processDate | [.[].changes[] | (.change | scan("\\b(submitted|rejected)=true\\b")[] | {submitted:"submission",rejected:"rejection"}[.]) as $type | {id, date, $type, user, $_processDate}]

  1. https://jqplay.org/s/ydoCgv9vsI
.objectEntries[].attributes |   {ticketid: . | map(select(.objectTypeAttributeId == 328))[0].objectAttributeValues[0].displayValue, date: . | map(select(.objectTypeAttributeId == 330))[0].objectAttributeValues[0].displayValue, hostnames: . | map(select(.objectTypeAttributeId == 329))[0] | [.objectAttributeValues[].displayValue]}

  1. https://jqplay.org/s/GV2zMjbCWK
.paths|{k:keys,v:map(keys)}

  1. https://jqplay.org/s/1jCG6soXuG
[to_entries[] | {value:(.value | arrays[] // .), type:.key}]

  1. https://jqplay.org/s/Ts97jkk21K
select(.potato as $k | ([1,2,3,4] | any(. == $k)))

  1. https://jqplay.org/s/RBBKMUS2pv
[inputs | select((. | length) > 1) | split("[[:space:]]+"; "") ] | reduce .[] as $item ({}; .[$item[2]]=$item[1])

  1. https://jqplay.org/s/ki8I1YnU56
map(.release_date = (.release_date | . as $date | try (strptime("%Y-%m-%d") | mktime) catch $date))

  1. https://jqplay.org/s/uBG5c969pf
{k:.id,m:([.j[] | select(.f==4)|.d][]//null)}

  1. https://jqplay.org/s/E8rS0Mf_so
{k:.id,m:.j[] | select(.f==3)|.d}

  1. https://jqplay.org/s/Lx7eM2akzp
{ "absolute": .t, "word": .s[]."$t", "relative": .s[].t, }

  1. https://jqplay.org/s/SI7XEMb5l9
{ widgets: (reduce . as $item ({}; . + {($item.name): {url: $item.url}})) }

  1. https://jqplay.org/s/exd2QjrS9V
{ errorMessage,errorCode,  orderId :  (.orderId |                               map({    (.orderId) : {   orderId ,          targetRequirements : (.targetRequirements |              map({             preferenceOrder               ,targetID             })            )      }   }) )  }

  1. https://jqplay.org/s/922RlkbFNA
.[] | { "y": .foo,  "x": .bar[] }| [.y,.x]  | @csv

  1. https://jqplay.org/s/3gulSlZiWz
.amazon| {  userType: .userType, userName: .user, itemCatalog: { 	 	itemId: .items[].id, 	name: .items[].name  } }

  1. https://jqplay.org/s/nM1WzWRmnK
{user: .results[].id, mail: .results[].buyer.email, buyer: .results[].buyer.billing_info.doc_number}

  1. https://jqplay.org/s/xQgpA4yJAz
map(select(.id == 1))

  1. https://jqplay.org/s/vt_4IbskaS
{CompletedInstances,status , "AppMap": (.serviceResponse |  map( { (.appId): .assets } ) | add ) }

  1. https://jqplay.org/s/Wx741btZOg
.a | .b | .c[] | .[] | .x = 97

  1. https://jqplay.org/s/-6c0QitFA7
.ideas | (map( { (.preference_order) : .ideaName } ) | add )

  1. https://jqplay.org/s/qfItW5U-Tf
.[].Config.Env |= reduce (.[] | split("=")) as [$key, $value] ({}; .[$key] = $value)

  1. https://jqplay.org/s/lh6QUQ0DO4
group_by(.id)[]|add

  1. https://jqplay.org/s/_RZNr_oYwE
.[] |  .product1.interval[] as $interval| {date: .date, time: ($interval.time//"N/A"), price: ($interval.price//-1)}

  1. https://jqplay.org/s/uRhNX-UglJ
.properties.periods[] | .shortForecast, .temperature, .windDirection, .windSpeed

  1. https://jqplay.org/s/7lBj_kDoB3
.[].output | scan("totalFailed+: [[:digit:]]+")

  1. https://jqplay.org/s/az56quLZa3
walk( if type=="array" and .[0].schema? then . + [{ "extra":"param" }] else . end)

  1. https://jqplay.org/s/CthSsOCQ-Y
[.[].methodResponse.params.param.value.struct.member[] | select(.name == "severity").value.string, select(.name == "product").value.string] | [{severity:.[0], product:.[1]}]

  1. https://jqplay.org/s/BWJwVdO3Zv
.[] as $parent | .[].behaviors[].name |  select(. == "redirect") | $parent

  1. https://jqplay.org/s/QTk42jn-a0
.id , (.records[].name + ":" + (.records[].value|tostring))

  1. https://jqplay.org/s/iEkMfm_u92
fromstream([ [ "foo", "a" ], 1 ],[ [ "foo", "b" ], 2 ],[ [ "foo", "b" ] ],[["foo"]],[ [ "bar", "a" ], 1 ],[ [ "bar", "b" ], 2 ],[ [ "bar", "b" ] ],[ [ "bar" ] ])

  1. https://jqplay.org/s/4aeBOY9x6q
.resources[] | select(.type == "Microsoft.ApiManagement/service/apis") as $apis | { types: [.type], apis: $apis}

  1. https://jqplay.org/s/By94hv9gKj
.[0] | {FirstItem1: .[0].items[0].firstitem1} + (.[1] | {seconditem: .[0].items[0].seconditem1})

  1. https://jqplay.org/s/XVgl5UCDLM
.priceDimensions |= { 	ufrontFee: .[] | select(.unit == "Quantity") | .USD,     hourFee:   .[] | select(.unit == "Hrs").USD }

  1. https://jqplay.org/s/h6_LfoEHLZ
.assets[] | select(.name=="atom-mac.zip") | .browser_download_url

  1. https://jqplay.org/s/beaibywO2k
.[] | select(.rooms[].furniture | length > 0) | .id

  1. https://jqplay.org/s/dGDswqAEte
.platforms[] | if ( .name=="CBus" ) then .accessories += [{ "values" : "NEW" }] else . end

  1. https://jqplay.org/s/OerK1MlARS
[.format.filename,.format.format_name,.format.tags.album_artist] | @csv

  1. https://jqplay.org/s/qXW_QUYFv0
delpaths([paths] | map(select(contains(["1234"]))))

  1. https://jqplay.org/s/SiFSE3RxZV
.Functions[] | select(.Layers[] | contains("layer2"))

  1. https://jqplay.org/s/BfAdRBZUMW
[group_by(.id)[]| add | { (.id) : . } ]|add

  1. https://jqplay.org/s/DsHYi7ixyn
.vertices | range(0;length) as $i | select(.[$i].alias=="polarized" and .[$i].ns=="ca") | $i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment