How do I use RANGE with a WHERE against a key

Sorry for this, but I have been searching and prodding my code and I cannot get this straight.

I am pulling an OpenAPI json document. That looks like this:

{
  "openapi": "3.0.1",
  "info": {
    "title": "WebApplication",
    "version": "v2"
  },
  "paths": {
    "/healthcheck": {
      "get": {
        "tags": [
          "Healthcheck"
        ],

I can range through all of them like so

{{ range $path, $pathMethods := $openapi.paths}}

What I have been trying to do is to add a where clause that only gets where the pages = “\healthcheck” for example. So the key when evaluating the paths structure.

I’ve ended up just putting in a {{ if eq $path "/healthcheck"}} inside the range, which works… but I was curious about how to work it into the where…

Thanks for any insight… I’m not finding any examples of it anywhere so starting to think it is not possible…

Bill

You can’t use where with this data structure. If you want to extract the “healthcheck” object:

{{ $foo := index $openapi.paths "/healthcheck" }}

Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.