Remove all null values
问题 I am trying to remove null values from a json object using jq. I found this issue on their github and so now I'm trying to remove them with del . I have this: '{ id: $customerId, name, phones: ([{ original: .phone }, { original: .otherPhone}]), email} | del(. | nulls)' This doesn't seem to do anything. However if I replace nulls with .phones it does remove the phone numbers. 回答1: The following illustrates how to remove all the null-valued keys from a JSON object: jq -n '{"a":1, "b": null, "c"