C# 听写在mongodb中存储错误

C# 听写在mongodb中存储错误,c#,mongodb,C#,Mongodb,我正试图将c#WebAPI中的数据存储到MongoDB数据库中。我面临的问题是我的数据之一是一本字典。我在调试时确实在c#中获得了正确序列化的数据,但当我将其存储到MongoDB中时,它存储为 "justice-supreme-court" : { "_t" : "Newtonsoft.Json.Linq.JArray, Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed",

我正试图将c#WebAPI中的数据存储到MongoDB数据库中。我面临的问题是我的数据之一是一本字典。我在调试时确实在c#中获得了正确序列化的数据,但当我将其存储到MongoDB中时,它存储为

"justice-supreme-court" : {
   "_t" : "Newtonsoft.Json.Linq.JArray, Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed",
   "_v" : [{
             "_t" : "JObject",
             "_v" : [{
                        "_t" : "JProperty",
                        "_v" : [{
                                   "_t" : "JValue",
                                   "_v" : [ ]
                                }]
                     }]
           }]
          },
    "referendum-michigan-up" : "yes"
},
根据其他帖子的建议,我尝试将字典类型更改为IDictionary,但没有任何帮助

这是我的目标

public class EncyptBallotDbObject 
{
    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; }

    [BsonElement("Ballot")]
    public Ballot Ballot { get; set; }
    public Dictionary<string, object> Votes { get; set; }

    //public Election? Election { get; set; }
    //public ElectionGuardConfig? ElectionGuardConfig { get; set; }
    //public ElectionMap? ElectionMap { get; set; }
    public string Tracker { get; set; }
    //public int? CurrentNumberOfBallots { get; set; }
    public string EncryptedBallotMessage { get; set; }
}

那么它不是字符串json的正确值吗?您能向我们展示一下您插入到数据库中的json数据吗?我不知道mongodb,它与dataytype大小有关吗?根据json,你的类结构应该是这样的公共类法官最高法院{public string id{get;set;}}}公共类投票{public IList justice supreme court{get;set;}公共类投票{get;set;}公共类投票}公共类投票{get;set;}`那么它不是字符串json的正确值吗?您能向我们展示一下您插入到数据库中的json数据吗?我不知道mongodb,它与dataytype大小有关吗?根据json,你的类结构应该是这样的公共类法官最高法院{public string id{get;set;}}}公共类投票{public IList justice supreme court{get;set;}公共类投票{get;set;}公共类投票}公共类投票{get;set;}`
 encyptballotDbObj.Ballot.Votes = request.Ballot.Votes;
 encyptballotDbObj.Votes = (Dictionary<string, object>)request.Ballot.Votes;
public IDictionary<string, object> Votes { get; set; }
"votes": {
    "justice-supreme-court" : [
        {
            "id": "laurel-clark"

        }
    ],
    "referendum-michigan-up" : "yes"
}