Artificial intelligent assistant

jq - print "-" for null values input json: { "id": "3885", "login": "050111", "lastLoginTime": 1529730115000, "lastLoginFrom": "192.168.66.230" } { "id": "3898", "login": "050112", "lastLoginTime": null, "lastLoginFrom": null } I want to get output for login, lastLoginTime and lastLoginFrom in tabulator delimited format: 050111 1529730115000 192.168.66.230 050112 - - with below jq filter I get on output no "null" values which I could replace with "-" $ jq -r '.|[.login, .lastLoginTime, .lastLoginFrom]|@tsv' test_json 050111 1529730115000 192.168.66.230 050112 Is there any other way to get "-" printed for such null values?

use the alternative operator: **//**

so :


$jq -r '.|[.login, .lastLoginTime // "-" , .lastLoginFrom // "-" ]|@tsv' test_json
050111 1529730115000 192.168.66.230
050112 - -

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 063c41fe4759c8be420e4073d6ac7bd3