You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
jq is a command line tool for parsing and modifying JSON. It is useful for extracting relevant bits of information from tools that output JSON, or REST APIs that return JSON. Mac users can install jq using homebrew (brew install jq); see here for more install options. In this post we'll examine a couple "real world" examples of using jq, but let's start with... jq BasicsThe most basic use is just
gojq is purely implemented with Go language and is completely portable. jq depends on the C standard library so the availability of math functions depends on the library. jq also depends on the regular expression library and it makes build scripts complex. gojq implements nice error messages for invalid query and JSON input. The error message of jq is sometimes difficult to tell where to fix the q
jqはとても便利なコマンドです。 JSONを返すAPIを実装するときや、SaaSのAPIから特定の情報を抜き出してシェル変数に代入するときなど、web開発や運用には欠かせないツールとなっています。 しかし、私にとってjqのクエリを一発で書くのは容易ではなく、思い通りの出力が得られないことがよくありました。 難しいエラーメッセージに悩まされて、jqで書くのを諦めて別の言語で書き直すこともありました。 jqの十八番と思える場面で使いこなせないのは、なかなか悔しいものがあります。 ツールを使うのが難しいなら、同じものを作ってしまえばよいのです。 jqの全ての機能を実装する jqを言語としてきちんと書けるようになる jqを完全に理解する jqの全ての機能を自分で実装してしまえば、jqがどういうものか、クエリがどのように処理されるのか、詳しくなれるはずです。 jqを得意な言語と言えるようになって、ク
jq 便利ですよね。 jq 使ってます。みんなあれ整形程度にしか使ってなかったり、絞込にしか使ってない気と思うんですよね jq である条件を満たすオブジェクトを取り出したい SQLのselect where みたいに select {} where [].name = 'takuya' みたいな jq がかけたら最高なんですよ。 条件マッチしたノードを取り出す例 $ echo '[ { "a":1 }, { "x": 1 } ]' | jq ' .[] | select(.x) ' { "x": 1 } 出来るんです。マニュアルに有りました。ああ。これは最高だ。 単純なところから、見ていく いきなり select 見ても何のことかわからないので、単純なところから見ていくことにする。 単純な整形 jq を使って整形をするよくある例です。これは jq . と書いてます。つまりカレントノードを出
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く