将MongoDB迁移到Azure CosmosDB失败;错误。 JsonReaderException - 解析NaN值时出错 [英] Migrate MongoDB to Azure CosmosDB Failed; error. JsonReaderException - Error parsing NaN value
问题描述
我上传了一个'.bson'文件并按照Microsoft迁移教程将MongoDB迁移到Azure CosmoDB服务。
I uploaded a '.bson' file and followed the Microsoft migration tutorial to migrate MongoDB to Azure CosmoDB services.
我收到以下错误:
错误。 JsonReaderException - 解析NaN值时出错。路径'$ v.ph. $ v',第1行,第658位。
error. JsonReaderException - Error parsing NaN value. Path '$v.ph.$v', line 1, position 658.
有什么想法我错过了什么?!
is there any idea what I have missed?!
验证并且已成功通过迁移的初始化 (基于迁移 日志文件),
validation and Initialization of the migration have been successfully passed (based on migration Log File),
推荐答案
嗨Mahdi,
Hi Mahdi,
您是否在解决方案中使用Json.Net NuGet包?我相信响应是bson格式,你需要将其解压缩或序列化为utf8 / json。一个示例方法:
Are you using a Json.Net NuGet package in your solution? I believe the response is in bson format and you need to decompress or serialize this to utf8/json. An example method:
private string ExtractJsonResponse(WebResponse response)
{
string json;
using (var outStream = new MemoryStream())
using (var zipStream = new GZipStream(response.GetResponseStream(),
CompressionMode.Decompress))
{
zipStream.CopyTo(outStream);
outStream.Seek(0, SeekOrigin.Begin);
using (var reader = new StreamReader(outStream, Encoding.UTF8))
{
json = reader.ReadToEnd();
}
}
return json;
}
并提取消息:
var json = ExtractJsonResponse(response);
我希望这是问题所在。谢谢,迈克
I hope this is the issue. Thanks, Mike
这篇关于将MongoDB迁移到Azure CosmosDB失败;错误。 JsonReaderException - 解析NaN值时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!