Using jq: Only select parents with a certain child key

Example json:

{
  "version": "3",
  "services": {
    "web": {
      "build": "web"
    },
    "redis": {
      "image": "redis"
    },
    "datadog": {
      "build": "datadog"
    },
    "another": {
      "image": "mysql"
    }
  }
}

I'd like to return a list of services that have the "build" key, and not the "image" key. Note that the value for the build key isn't something I can key off of.

Output should be: ["web", "datadog"]

#json

2 Likes98.35 GEEK