4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

例えば

  • AWS CLI で --query オプションを使うとき,とかに使ったりする

jq にパイプしないでもいい感じにできると嬉しい.
自分が知りたいことを書く

オブジェクトを潜る

. を使ったりする

$ echo '{"k1": { "k2" : "value" } }' | jp k1.k2
"value"

filter する

? が使えそう

$ echo '{"foo": {"bar": [{"k":"a","x":1},{"k":"b","x":2},{"k":"c","x":3}]}}' | jp 'foo.bar[?k == `"a"`]'
[
  {
    "k": "a",
    "x": 1
  }
]

リテラル

`"a"` みたいな,` で囲わないといけないのを知らないとハマりそう.

リストの中のattr の value 取る

$ echo '[{"a":1},{"a":2}]'|jp '[*].a'
[
  1,
  2
]

Refs

$ brew install jmespath/jmespath/jp
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?