Firebase - Invalid JSON data or key values. Key values can’t contain $ # [ ] / or

后端 未结 9 2179
陌清茗
陌清茗 2020-12-31 03:34

I\'m trying to import my JSON file into my Firebase but it keeps giving me this error. I don\'t know why this JSON file isn\'t allowed to be imported into since JSONLint say

相关标签:
9条回答
  • 2020-12-31 04:24

    This happened to me, and had a totally different cause: I had Firebase functions that triggered when data is added to certain collections. The GUI tool gave me the unhelpful error the OP got. But running with the CLI, I got:

    Error: HTTP Error: 400, This request would cause too many functions to be triggered.
    

    So, the error ended up really saving my hide since running a function for each of the few hundred nodes I was importing would have been disastrous.

    To solve the issue, I deployed my app code with the functions commented out and then was able to use the GUI to import my data. Once my data was in, I un-commented out the functions and deployed again.

    0 讨论(0)
  • 2020-12-31 04:27

    I just found one more reason when Firebase throws this error:

    This was the data firebase refused to upload:

     {
                "S. No.": 2,
                "University Name": "Acharya Nagarjuna University, Guntur (Id: U-0003)",
                "College Name": "Abhinav Institute of Management & Technology (Id: C-39450)",
                "College Type": "Affiliated College",
                "State Name": "Andhra Pradesh",
                "District Name": "Prakasam"
              } 
    

    I thought of changing the key name of "S. No." and it worked.

    {
                "S": 2,
                "University Name": "Acharya Nagarjuna University, Guntur (Id: U-0003)",
                "College Name": "Abhinav Institute of Management & Technology (Id: C-39450)",
                "College Type": "Affiliated College",
                "State Name": "Andhra Pradesh",
                "District Name": "Prakasam"
              } 
    

    The Firebase was accepting the later format (I believe the problem was with .(dot) followed by space.) I hope this helps!!!

    0 讨论(0)
  • 2020-12-31 04:27

    I have a similar problem with JSON containing huge data. I solved this problem by using firebase import tool. It has options for imports to specific nodes etc.

    0 讨论(0)
提交回复
热议问题