Support multi-line strings in Database rules JSON
See original GitHub issueI’m trying to do a simple database rules deploy using version 3.6.0 and I recieve the following error on the CL.
Error: There was an error loading firebase.json:
Unexpected token ' ' at 6:35
".write": "data.exists() &&
^
Having trouble? Try firebase deploy --help
My rules are saved in a file ‘database_rules.json’, my firebase.json file looks like this:
{
"rules": "database_rules.json",
"hosting": {
"public": "./",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**",
"functions",
"gulpfile.js"
]
}
}
My rules are the following:
{
"rules": {
".validate": "auth !== null",
"_const": {
".read":"true",
".write": "data.exists() &&
newData.exists()"
}
}
}
I was under the impression multi-line strings were OK, as they publish fine in the rules editor on the console. If this is intended, what’s the work-around to get this to deploy whilst preserving the newlines so they stay readable in the console?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Are multi-line strings allowed in JSON? - Stack Overflow
While not standard, I found that some of the JSON libraries have options to support multiline Strings. I am saying this with the...
Read more >Security Rules language - Firebase - Google
Realtime Database rules use a syntax that looks like JavaScript in a JSON ... The Firebase Security Rules language also supports function declarations....
Read more >Storing multi-line strings in JSON with JSONLint - Gun.io
This quick hack helps find a way to store multi-line strings in JSON to interact with JS and Node.
Read more >How to Collect and Manage All of Your Multi-Line Logs
Logging to JSON. The simplest way to ensure that your multi-line logs are processed as single events is to log to JSON. For...
Read more >An Introduction to JSON | DigitalOcean
Each of the data types that are passed in as values into JSON will maintain their own syntax, meaning strings will be in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Multi-line strings are not currently supported by the CLI when deploying rules. I’ll change the title of this to reflect that as a bug/feature request.
Thanks for the tip @samtstern but how that helps? Broken strings are also a syntax error on JS unless you use inverted ticks
``
And if that is supported inside a JSON file, at that point the file may be better defined as a JS file insted