【发布时间】:2019-03-11 01:13:27
【问题描述】:
我在 MongoDB 中插入了以下 JSON 文件
"entities": [{
"type": "Location",
"text": "Marília",
"relevance": 0.966306,
"disambiguation": {
"subtype": [
"CityTown",
"City"
],
"name": "Marília",
"dbpedia_resource": "http://dbpedia.org/resource/Marília"
},
"count": 3
},
{
"type": "Organization",
"text": "Associação Engenheiros, Arquitetos",
"relevance": 0.647857,
"count": 1
}
]
在 MongoDB 中,type 是保留字。如何将type 键更改为desctype?我正在使用 NodeJS。
我已经试过了:
data = JSON.stringify(data).replace(/"type"/g, /"desctype"/);
data = JSON.parse(data);
但我有错误:
JSON.parse: SyntaxError: Unexpected token / in JSON
【问题讨论】:
标签: javascript json node.js mongodb mongoose