首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用数据库的正确格式:使用firebase-tools设置

使用数据库的正确格式:使用firebase-tools设置
EN

Stack Overflow用户
提问于 2017-05-20 15:37:35
回答 1查看 656关注 0票数 0

因此,从我所读到的所有内容来看,在全局安装了firebase-tools后,我的Windows命令提示符在包含我的项目的文件夹中打开,一个工作的firebase.json文件(在firebase deploy works中工作得很好),我应该能够运行以下命令来覆盖我的firebase数据库的全部内容:

代码语言:javascript
复制
firebase database:set / database.json

然而,使用database.json时,我得到了以下错误:

代码语言:javascript
复制
Error: HTTP Error: 400, Invalid data; couldn't parse JSON object, array, or value.

database.json包含以下内容:

代码语言:javascript
复制
{
  "catalogue": {
    "csi": {
      "descriptionRoute": "csi",
      "fileName": "ctk%20Currency%20Strength%20Indicator.algo",
      "id": 1,
      "imageUrl": "/images/csi.png",
      "isFeatured": true,
      "name": "Currency Strength Indicator",
      "shortDescription": "Plots the relative strength of 8 major currencies as a line chart",
      "type": "indicator"
    },
    "csh": {
      "descriptionRoute": "csh",
      "fileName": "ctk%20Currency%20Strength%20Heatmap.algo",
      "id": 2,
      "imageUrl": "/images/csh.png",
      "isFeatured": true,
      "name": "Currency Strength Heatmap",
      "shortDescription": "Plots the relative strength of 8 major currencies as a heatmap",
      "type": "indicator"
    },
    "ffc": {
      "descriptionRoute": "ffc",
      "fileName": "ctk%20FF%20Calendar.algo",
      "id": 3,
      "imageUrl": "/images/ffc.png",
      "isFeatured": true,
      "name": "Forex Factory Calendar",
      "shortDescription": "Lists upcoming events from the Forex Factory RSS feed",
      "type": "indicator"
    },
    "atrsl": {
      "descriptionRoute": "atrsl",
      "fileName": "ctk%20ATR%20Stop%20Loss%20Indicator.algo",
      "id": 4,
      "imageUrl": "/images/atrsl.png",
      "isFeatured": false,
      "name": "ATR Stop Loss Indicator",
      "shortDescription": "Displays ATR and stop loss values based on your requirements.",
      "type": "indicator"
    },
    "ha": {
      "descriptionRoute": "ha",
      "fileName": "ctk%20Heken%20Ashi.algo",
      "id": 5,
      "imageUrl": "/images/ha.png",
      "isFeatured": false,
      "name": "Heiken Ashi",
      "shortDescription": "Paints Heiken Ashi candles on the host chart.",
      "type": "indicator"
    },
    "hama": {
      "descriptionRoute": "hama",
      "fileName": "ctk%20Heken%20Ashi%20Moving%20Average.algo",
      "id": 6,
      "imageUrl": "/images/hama.png",
      "isFeatured": false,
      "name": "Heiken Ashi Moving Average",
      "shortDescription": "Paints Heiken Ashi Moving Average on the host chart.",
      "type": "indicator"
    },
    "psl": {
      "descriptionRoute": "psl",
      "fileName": "ctk%20Psych%20Levels%20.algo",
      "id": 7,
      "imageUrl": "/images/psl.png",
      "isFeatured": false,
      "name": "Psych Levels",
      "shortDescription": "Draws lines at psychological levels that often form string Support and Resistance",
      "type": "indicator"
    }
  }
}

我看不出这有什么问题,我在谷歌上搜索的所有东西都表明它是正常的,但我只能得到错误。

所以我跑了

代码语言:javascript
复制
firebase database:get / > database2.json

结果如下:

代码语言:javascript
复制
{
  "catalogue": [
    null,
    {
      "descriptionRoute": "csi",
      "fileName": "ctk%20Currency%20Strength%20Indicator.algo",
      "id": 1,
      "imageUrl": "/images/csi.png",
      "isFeatured": true,
      "name": "Currency Strength Indicator",
      "shortDescription": "Plots the relative strength of 8 major currencies as a line chart",
      "type": "indicator"
    },
    {
      "descriptionRoute": "csh",
      "fileName": "ctk%20Currency%20Strength%20Heatmap.algo",
      "id": 2,
      "imageUrl": "/images/csh.png",
      "isFeatured": true,
      "name": "Currency Strength Heatmap",
      "shortDescription": "Plots the relative strength of 8 major currencies as a heatmap",
      "type": "indicator"
    },
    {
      "descriptionRoute": "ffc",
      "fileName": "ctk%20FF%20Calendar.algo",
      "id": 3,
      "imageUrl": "/images/ffc.png",
      "isFeatured": true,
      "name": "Forex Factory Calendar",
      "shortDescription": "Lists upcoming events from the Forex Factory RSS feed",
      "type": "indicator"
    },
    {
      "descriptionRoute": "atrsl",
      "fileName": "ctk%20ATR%20Stop%20Loss%20Indicator.algo",
      "id": 4,
      "imageUrl": "/images/atrsl.png",
      "isFeatured": false,
      "name": "ATR Stop Loss Indicator",
      "shortDescription": "Displays ATR and stop loss values based on your requirements.",
      "type": "indicator"
    }
  ]
}

然后马上就跑了

firebase数据库:set/ database2.json

得到了同样的错误。我被难住了,如果下载的数据格式不能上传,我需要什么格式?

EN

回答 1

Stack Overflow用户

发布于 2017-05-21 19:34:00

我解决了这个问题,正如Bob Snyder所暗示的,问题出在文件的编码上。

我最初是从Visual Studio 2017中的JSON文件模板创建该文件的。为了检查编码,我在NotePad++中打开它,它显示编码为UTF-8-BOM。我在NP++中将编码更改为UTF-8,并运行原始命令:

代码语言:javascript
复制
firebase database:set / database.json

它第一次工作了,我的数据库被覆盖了。

因此,对于遇到此问题的任何其他人,请确保JSON文件的编码为UTF-8。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44083218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档