sharepoint online – How to change the color of odd and even rows of a list

You can add multiple classes in additionalRowClass property in above JSON as per your requirement.

For example, to change the color of rows with gray background to blue, you need to add ms-fontColor-blue class to the first condition, like:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "additionalRowClass": {
    "operator": ":",
    "operands": [
      {
        "operator": "==",
        "operands": [
          {
            "operator": "%",
            "operands": [
              "@rowIndex",
              2
            ]
          },
          0
        ]
      },
      "sp-css-backgroundColor-neutralBackground ms-fontColor-blue",
      {
        "operator": ":",
        "operands": [
          {
            "operator": "==",
            "operands": [
              {
                "operator": "%",
                "operands": [
                  "@rowIndex",
                  2
                ]
              },
              1
            ]
          },
          "sp-css-backgroundColor-noFill",
          ""
        ]
      }
    ]
  }
}

You can find more predefined classed you can use in JSON formatting at:

  1. Predefined classes
  2. Reusable SharePoint Online Classes for Modern UI

Note: In SharePoint JSON formatting, @rowIndex starts with 0.