diff --git a/jq.md b/jq.md index 96236f8..fd69a5f 100644 --- a/jq.md +++ b/jq.md @@ -1 +1,30 @@ -example \ No newline at end of file +## null + +`id:3`の`name:null`を除外して表示 + +```json +[ + { + "id": 1, + "name": "aios", + "display": "ai os" + }, + { + "id": 2, + "name": "archlinux", + "display": "Arch Linux" + }, + { + "id": 3, + "display": "Linux Kernel" + } +] +``` + +```sh +$ echo $json|jq -r ".[]|{name, display}|select(.name | length > 0)|.name,.display" +aios +ai os +archlinux +Arch Linux +``` \ No newline at end of file