restish icon indicating copy to clipboard operation
restish copied to clipboard

Recursive decent inserting nils

Open manther opened this issue 3 years ago • 0 comments

Given an endpoint that returns a repetitive structure with no nil value results such as:

[
  {
    fqdn: ""
    id: "f44ef09a-102f-4a98-952e-04b64fe2b2bd"
    state: ""
  }
  {
    fqdn: "node2"
    id: "1af9adc3-acad-47f8-8120-8fee87d809ae"
    state: ""
  }
  {
    fqdn: "node3"
    id: "710a97dd-dbe5-41c5-acd2-db842da655eb"
    state: ""
  }
]

trying to use the recursive decent feature:

get-nodes -f ..{id}

results in output that has extraneous nulls inserted:

[
  {
    "id": null
  },
  {
    "id": null
  },
  {
    "id": "f44ef09a-102f-4a98-952e-04b64fe2b2bd"
  },
  {
    "id": "1af9adc3-acad-47f8-8120-8fee87d809ae"
  },
  {
    "id": "710a97dd-dbe5-41c5-acd2-db842da655eb"
  },
  {
    "id": null
  }
]

However if I do not use recursive decent it does not insert those nil results in.

get-nodes -f "body[].{id}"

result:

[
  {
    "id": "f44ef09a-102f-4a98-952e-04b64fe2b2bd"
  },
  {
    "id": "1af9adc3-acad-47f8-8120-8fee87d809ae"
  },
  {
    "id": "710a97dd-dbe5-41c5-acd2-db842da655eb"
  }
]

manther avatar Dec 22 '21 21:12 manther