Attempting to print data formatted in a specific way, but the conditional doesn't work correctly.

I've written a simple test:

jq -r ". | if (.[].nickname | length) >15 then \"\(.[].nickname)\t\(.[].fingerprint)\" else \"no\" end" running.json

Where running.json is this sample json:

[
  {
    "nickname": "FiverInstitute11",
    "fingerprint": "0011BD2J8D3J45D984EC4159C88FC066E5E3300E",
  },
  {
    "nickname": "Something13",
    "fingerprint": "0077BCBA7244DB3E6O2AD274H886170066684887",
  },
  {
    "nickname": "je8gvke8s2ff063CMbc",
    "fingerprint": "00B87ECU71DBF56805NE8469BAF3924A13AD7",
  },
  {
    "nickname": "test931",
    "fingerprint": "00DC112F7D469AD7E0E4B378D050490811BB20E5",
  }
]

The output never prints "no" even in the case that the conditional is false. Anyone know how this is fixed?

0 Answers