我使用 DocumentDB 数据迁移工具导入了一个包含 4 个文档的 .json 文件,它对我来说效果很好。
我的.json 文件:
[
{
"name":"jay1",
"age":20
},
{
"name":"jay2",
"age":20
},
{
"name":"jay3",
"age":20
},
{
"name":"jay4",
"age":20
}
]
文档分别导入到集合中。
JSON 文件源导入器选项允许您导入一个或多个
单个文档 JSON 文件或 JSON 文件,每个文件都包含一个数组
JSON 文档。添加包含要导入的 JSON 文件的文件夹时,
您可以选择递归搜索子文件夹中的文件。
您可以检查您是否遵循official tutorial 中所述的上述规则来创建您的 .json 文件。 (例如,您的文档是否在数组中?)
希望对你有帮助。
更新答案:
我厌倦了将遵循您在回复中提到的格式的数据导入cosmos db。
我的更新.json文件:
[
{
"id":"001",
"name":"jay1",
"age":20,
"array": {
"a":1,
"b":2,
"c":{
"d":3,
"e": {
"f":4
}
}
}
},
{
"id":"002",
"name":"jay2",
"age":20,
"array": {
"a":1,
"b":2,
"c":{
"d":3,
"e": {
"f":4
}
}
}
},
{
"id":"003",
"name":"jay3",
"age":20,
"array": {
"a":1,
"b":2,
"c":{
"d":3,
"e": {
"f":4
}
}
}
}
]
文档成功导入集合。
更新答案 2:
我按照您提供的文档格式在我的 .json 文件中创建了 3 个示例文档。(我只是将“_id”属性更新为“testX”)
我的.json 文件:
[
{
"_id": "test1",
"_rev": "3-99aef1458fe1a8f310c83156b9d06a69",
"delivery": {
"application": "EnvTest",
"sender": {
"id": "RXMARTINEZ@emailaddress.com",
"type": "user"
},
"recipients": [
{
"type": "email",
"recipient": "\"Artzer, Daniel J\" <DJArtzer@emailaddress.com>",
"sentTS": "2018-01-30T19:46:31.515Z",
"id": "45281ab0-05f6-11e8-a86a-61a54dcb42aa"
}
]
},
"payload": {
"startTS": "2017-11-30T07:38:33-06:00",
"equipmentOrLineType": "gathering system",
"scheduledIndicator": "upset",
"field": "Gulf Plains",
"eventDateTime": "2017-11-30T07:31:39-06:00",
"numCopies": "1",
"region": "South",
"facility": "",
"equipment": "",
"causeForRelease": "",
"correctiveAction": "",
"hgbUsed": "no-hgb-available",
"esdActivated": "no",
"submitTS": "2017-11-30T13:38:33.940Z",
"lineSegment": [
{
"lineName": "GPL-1",
"Diameter": "12.725",
"Length": "1000",
"duration": "no",
"volume": "3"
}
],
"creator": "RXMARTINEZ@emailaddress.com",
"savedTS": "2017-11-30T13:38:33.955Z",
"trainingDoc": true,
"_id": "bd_RXMARTINEZ@emailaddress.com_2017-11-30T13:38:33.955Z",
"syncTS": "2017-11-30T13:38:34.794Z"
}
},
{
"_id": "test2",
"_rev": "3-99aef1458fe1a8f310c83156b9d06a69",
"delivery": {
"application": "EnvTest",
"sender": {
"id": "RXMARTINEZ@emailaddress.com",
"type": "user"
},
"recipients": [
{
"type": "email",
"recipient": "\"Artzer, Daniel J\" <DJArtzer@emailaddress.com>",
"sentTS": "2018-01-30T19:46:31.515Z",
"id": "45281ab0-05f6-11e8-a86a-61a54dcb42aa"
}
]
},
"payload": {
"startTS": "2017-11-30T07:38:33-06:00",
"equipmentOrLineType": "gathering system",
"scheduledIndicator": "upset",
"field": "Gulf Plains",
"eventDateTime": "2017-11-30T07:31:39-06:00",
"numCopies": "1",
"region": "South",
"facility": "",
"equipment": "",
"causeForRelease": "",
"correctiveAction": "",
"hgbUsed": "no-hgb-available",
"esdActivated": "no",
"submitTS": "2017-11-30T13:38:33.940Z",
"lineSegment": [
{
"lineName": "GPL-1",
"Diameter": "12.725",
"Length": "1000",
"duration": "no",
"volume": "3"
}
],
"creator": "RXMARTINEZ@emailaddress.com",
"savedTS": "2017-11-30T13:38:33.955Z",
"trainingDoc": true,
"_id": "bd_RXMARTINEZ@emailaddress.com_2017-11-30T13:38:33.955Z",
"syncTS": "2017-11-30T13:38:34.794Z"
}
},
{
"_id": "test3",
"_rev": "3-99aef1458fe1a8f310c83156b9d06a69",
"delivery": {
"application": "EnvTest",
"sender": {
"id": "RXMARTINEZ@emailaddress.com",
"type": "user"
},
"recipients": [
{
"type": "email",
"recipient": "\"Artzer, Daniel J\" <DJArtzer@emailaddress.com>",
"sentTS": "2018-01-30T19:46:31.515Z",
"id": "45281ab0-05f6-11e8-a86a-61a54dcb42aa"
}
]
},
"payload": {
"startTS": "2017-11-30T07:38:33-06:00",
"equipmentOrLineType": "gathering system",
"scheduledIndicator": "upset",
"field": "Gulf Plains",
"eventDateTime": "2017-11-30T07:31:39-06:00",
"numCopies": "1",
"region": "South",
"facility": "",
"equipment": "",
"causeForRelease": "",
"correctiveAction": "",
"hgbUsed": "no-hgb-available",
"esdActivated": "no",
"submitTS": "2017-11-30T13:38:33.940Z",
"lineSegment": [
{
"lineName": "GPL-1",
"Diameter": "12.725",
"Length": "1000",
"duration": "no",
"volume": "3"
}
],
"creator": "RXMARTINEZ@emailaddress.com",
"savedTS": "2017-11-30T13:38:33.955Z",
"trainingDoc": true,
"_id": "bd_RXMARTINEZ@emailaddress.com_2017-11-30T13:38:33.955Z",
"syncTS": "2017-11-30T13:38:34.794Z"
}
}
]
文档已导入数据库,没有发生错误。
如果你我之间有什么不同,请告诉我。