RESTful json_attributes_path array search problem

I’m trying to parse out some additional info about current Dominant Pollutant from Google’s Air Quiality API.
JSON:

{
  "dateTime": "2025-12-17T18:00:00Z",
  "regionCode": "us",
  "indexes": [
    {
      "code": "usa_epa_nowcast",
      "displayName": "AQI (US)",
      "aqi": 59,
      "aqiDisplay": "59",
      "color": {
        "red": 1,
        "green": 1
      },
      "category": "Moderate air quality",
      "dominantPollutant": "pm25"
    }
  ],
  "pollutants": [
    {
      "code": "o3",
      "displayName": "O3",
      "fullName": "Ozone",
      "concentration": {
        "value": 12.16,
        "units": "PARTS_PER_BILLION"
      }
    },
    {
      "code": "pm10",
      "displayName": "PM10",
      "fullName": "Inhalable particulate matter (\u003c10µm)",
      "concentration": {
        "value": 28.59,
        "units": "MICROGRAMS_PER_CUBIC_METER"
      }
    },
    {
      "code": "pm25",
      "displayName": "PM2.5",
      "fullName": "Fine particulate matter (\u003c2.5µm)",
      "concentration": {
        "value": 15.17,
        "units": "MICROGRAMS_PER_CUBIC_METER"
      }
    },
    {
      "code": "co",
      "displayName": "CO",
      "fullName": "Carbon monoxide",
      "concentration": {
        "value": 567.15,
        "units": "PARTS_PER_BILLION"
      }
    },
    {
      "code": "so2",
      "displayName": "SO2",
      "fullName": "Sulfur dioxide",
      "concentration": {
        "value": 0.56,
        "units": "PARTS_PER_BILLION"
      }
    },
    {
      "code": "no2",
      "displayName": "NO2",
      "fullName": "Nitrogen dioxide",
      "concentration": {
        "value": 25.75,
        "units": "PARTS_PER_BILLION"
      }
    }
  ]
}

Current dominant pollutant value is at $.indexes[0].dominantPollutant.
According to https://jsonpath.com, it should be possible to achieve for both JSONPath Plus: $.pollutants[?(@.code == @root.indexes[0].dominantPollutant)]
and RFC9535: $.pollutants[?(@.code == $.indexes[0].dominantPollutant)]

But when I try to plug any of above to my sensor:

    json_attributes_path: '$.pollutants[?(@.code == @root.indexes[0].dominantPollutant)]'
    json_attributes:
      - displayName
      - fullName

getting following errors for both:

2025-12-17 13:08:08.938 WARNING (MainThread) [homeassistant.components.rest.util] JSON result was not a dictionary or list with 0th element a dictionary

Any clue what JSONPath engine HA is using?

You see how your response has brackets?

That means the result is a list.

The error you’re getting says:

So it would need to be a list with a single element that is a dictionary or a dictionary.

Your output appears to be a list with a single element that is a dictionary, so it should work with $.pollutants[?(@.code == $.indexes[0].dominantPollutant)]

Your next step should be enable debug logging for rest and see what HA’s actually getting as a response.

Enabling logging does not help much:

logger:
  logs:
    homeassistant.components.rest: debug
2025-12-18 08:48:43.266 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource: {
  "dateTime": "2025-12-18T14:00:00Z",
  "regionCode": "us",
  "indexes": [
    {
      "code": "usa_epa_nowcast",
      "displayName": "AQI (US)",
      "aqi": 59,
      "aqiDisplay": "59",
      "color": {
        "red": 1,
        "green": 1
      },
      "category": "Moderate air quality",
      "dominantPollutant": "pm25"
    }
  ],
  "pollutants": [
    {
      "code": "o3",
      "displayName": "O3",
      "fullName": "Ozone",
      "concentration": {
        "value": 14.74,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Ozone is created in a chemical reaction between atmospheric oxygen, nitrogen oxides, carbon monoxide and organic compounds, in the presence of sunlight.",
        "effects": "Ozone can irritate the airways and cause coughing, a burning sensation, wheezing and shortness of breath. Additionally, ozone is one of the major components of photochemical smog."
      }
    },
    {
      "code": "pm10",
      "displayName": "PM10",
      "fullName": "Inhalable particulate matter (\u003c10µm)",
      "concentration": {
        "value": 36.57,
        "units": "MICROGRAMS_PER_CUBIC_METER"
      },
      "additionalInfo": {
        "sources": "Main sources are combustion processes (e.g. indoor heating, wildfires), mechanical processes (e.g. construction, mineral dust, agriculture) and biological particles (e.g. pollen, bacteria, mold).",
        "effects": "Inhalable particles can penetrate into the lungs. Short term exposure can cause irritation of the airways, coughing, and aggravation of heart and lung diseases, expressed as difficulty breathing, heart attacks and even premature death."
      }
    },
    {
      "code": "pm25",
      "displayName": "PM2.5",
      "fullName": "Fine particulate matter (\u003c2.5µm)",
      "concentration": {
        "value": 13.89,
        "units": "MICROGRAMS_PER_CUBIC_METER"
      },
      "additionalInfo": {
        "sources": "Main sources are combustion processes (e.g. power plants, indoor heating, car exhausts, wildfires), mechanical processes (e.g. construction, mineral dust) and biological particles (e.g. bacteria, viruses).",
        "effects": "Fine particles can penetrate into the lungs and bloodstream. Short term exposure can cause irritation of the airways, coughing and aggravation of heart and lung diseases, expressed as difficulty breathing, heart attacks and even premature death."
      }
    },
    {
      "code": "co",
      "displayName": "CO",
      "fullName": "Carbon monoxide",
      "concentration": {
        "value": 300.13,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Typically originates from incomplete combustion of carbon fuels, such as that which occurs in car engines and power plants.",
        "effects": "When inhaled, carbon monoxide can prevent the blood from carrying oxygen. Exposure may cause dizziness, nausea and headaches. Exposure to extreme concentrations can lead to loss of consciousness."
      }
    },
    {
      "code": "so2",
      "displayName": "SO2",
      "fullName": "Sulfur dioxide",
      "concentration": {
        "value": 0.41,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Main sources are burning processes of sulfur-containing fuel in industry, transportation and power plants.",
        "effects": "Exposure causes irritation of the respiratory tract, coughing and generates local inflammatory reactions. These in turn, may cause aggravation of lung diseases, even with short term exposure."
      }
    },
    {
      "code": "no2",
      "displayName": "NO2",
      "fullName": "Nitrogen dioxide",
      "concentration": {
        "value": 14.55,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Main sources are fuel burning processes, such as those used in industry and transportation.",
        "effects": "Exposure may cause increased bronchial reactivity in patients with asthma, lung function decline in patients with Chronic Obstructive Pulmonary Disease (COPD), and increased risk of respiratory infections, especially in young children."
      }
    }
  ]
}

2025-12-18 08:48:43.269 WARNING (MainThread) [homeassistant.components.rest.util] JSON result was not a dictionary or list with 0th element a dictionary
2025-12-18 08:48:43.271 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource: {
  "dateTime": "2025-12-18T14:00:00Z",
  "regionCode": "us",
  "indexes": [
    {
      "code": "usa_epa_nowcast",
      "displayName": "AQI (US)",
      "aqi": 59,
      "aqiDisplay": "59",
      "color": {
        "red": 1,
        "green": 1
      },
      "category": "Moderate air quality",
      "dominantPollutant": "pm25"
    }
  ],
  "pollutants": [
    {
      "code": "o3",
      "displayName": "O3",
      "fullName": "Ozone",
      "concentration": {
        "value": 14.74,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Ozone is created in a chemical reaction between atmospheric oxygen, nitrogen oxides, carbon monoxide and organic compounds, in the presence of sunlight.",
        "effects": "Ozone can irritate the airways and cause coughing, a burning sensation, wheezing and shortness of breath. Additionally, ozone is one of the major components of photochemical smog."
      }
    },
    {
      "code": "pm10",
      "displayName": "PM10",
      "fullName": "Inhalable particulate matter (\u003c10µm)",
      "concentration": {
        "value": 36.57,
        "units": "MICROGRAMS_PER_CUBIC_METER"
      },
      "additionalInfo": {
        "sources": "Main sources are combustion processes (e.g. indoor heating, wildfires), mechanical processes (e.g. construction, mineral dust, agriculture) and biological particles (e.g. pollen, bacteria, mold).",
        "effects": "Inhalable particles can penetrate into the lungs. Short term exposure can cause irritation of the airways, coughing, and aggravation of heart and lung diseases, expressed as difficulty breathing, heart attacks and even premature death."
      }
    },
    {
      "code": "pm25",
      "displayName": "PM2.5",
      "fullName": "Fine particulate matter (\u003c2.5µm)",
      "concentration": {
        "value": 13.89,
        "units": "MICROGRAMS_PER_CUBIC_METER"
      },
      "additionalInfo": {
        "sources": "Main sources are combustion processes (e.g. power plants, indoor heating, car exhausts, wildfires), mechanical processes (e.g. construction, mineral dust) and biological particles (e.g. bacteria, viruses).",
        "effects": "Fine particles can penetrate into the lungs and bloodstream. Short term exposure can cause irritation of the airways, coughing and aggravation of heart and lung diseases, expressed as difficulty breathing, heart attacks and even premature death."
      }
    },
    {
      "code": "co",
      "displayName": "CO",
      "fullName": "Carbon monoxide",
      "concentration": {
        "value": 300.13,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Typically originates from incomplete combustion of carbon fuels, such as that which occurs in car engines and power plants.",
        "effects": "When inhaled, carbon monoxide can prevent the blood from carrying oxygen. Exposure may cause dizziness, nausea and headaches. Exposure to extreme concentrations can lead to loss of consciousness."
      }
    },
    {
      "code": "so2",
      "displayName": "SO2",
      "fullName": "Sulfur dioxide",
      "concentration": {
        "value": 0.41,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Main sources are burning processes of sulfur-containing fuel in industry, transportation and power plants.",
        "effects": "Exposure causes irritation of the respiratory tract, coughing and generates local inflammatory reactions. These in turn, may cause aggravation of lung diseases, even with short term exposure."
      }
    },
    {
      "code": "no2",
      "displayName": "NO2",
      "fullName": "Nitrogen dioxide",
      "concentration": {
        "value": 14.55,
        "units": "PARTS_PER_BILLION"
      },
      "additionalInfo": {
        "sources": "Main sources are fuel burning processes, such as those used in industry and transportation.",
        "effects": "Exposure may cause increased bronchial reactivity in patients with asthma, lung function decline in patients with Chronic Obstructive Pulmonary Disease (COPD), and increased risk of respiratory infections, especially in young children."
      }
    }
  ]
}

One thing I missed to mention: it works for “constants”, like $.pollutants[?(@.code == "pm25")], but doesn’t work for “variables”: $.pollutants[?(@.code == @root.indexes[0].dominantPollutant)]

Guess this is some limitation of underlying parsing library.