0
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?

More than 1 year has passed since last update.

jqで対応するキーがない場合にnullではなく空文字を返す

Last updated at Posted at 2023-06-28

Alternative operator // を使う

Perlで言うところのDefined-or演算子
とっても検索しづらい

これと何も返さないemptyを組み合わせる
もちろん適当なデフォルト値を設定することもできる

サンプル

{"hoge": 1}
$ jq .foo // empty
# 何も返ってこない

参考

0
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
0
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?