'firebase rules - Error saving rules – Line 2: Expected '"'

Error saving rules – Line 2: Expected '"'.

{
  "rules": {
    "Users": {
      ".read": true
      "$uid": {
        ".write": "$uid === auth.uid"
      }
    }
  }
}

Can anyone help, I really can't see where I'm missing a " on line 2?



Solution 1:[1]

I get a different error on those exact rules:

Error saving rules - Line 5: Expected ',' or '}'.

You need a comma after ".read": true":

{
  "rules": {
    "Users": {
      ".read": true,
      "$uid": {
        ".write": "$uid === auth.uid"
      }
    }
  }
}

Solution 2:[2]

I had a similar problem. So I noticed that it happens whenever i copy rules elsewhere and then paste them in firebase. I also noticed that the copied quotation marks from Word, were different from the ones in firebase. So I deleted the quotation marks and retype them and it worked.

I have attached a screenshot to show the differences between the quotation marks. Hope that is helpful.Firebase rules screenshot to solve Error saving rules - Line 2: Expected ""

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doug Stevenson
Solution 2 Likhwa Milton Moyo