I am trying to insert data in mongodb by using BsonDocument. it inserting the data like following .
{
"_id" : ObjectId("5bf3eae0118cd3f6140aee72"),
"_t" : "MongoDB.Bson.BsonDocument, MongoDB.Bson",
"_v" : {
"_t" : "Newtonsoft.Json.Linq.JObject, Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed",
"_v" : {
"Email" : {
"_t" : "JValue",
"_v" : []
},
"Password" : {
"_t" : "JValue",
"_v" : []
}
}
}
}
The bellow code is i am using
public void Post([FromBody] Object value)
{
var document = new BsonDocument ();
document.AddRange(value.ToBsonDocument());
_database.GetCollection<dynamic>("Registeration").InsertOneAsync(document);
//Console.WriteLine("Success") ;
}
In this i am using .net core api without model class.How can i insert the data in correct way. Please any one try to help me.
Thank you...
valueactually coming from when fed into the function? The malformed fields would indicate that you are attempting to parse JSON. So your question really should be "How to marshal JSON into a BsonDocument". That's a clear title. Basically you need to show how you are reading the JSON as well. That's the real problem.mongoshell as I would recommend for questions posted here. Pictures just don't translate well and was in fact totally missed by the first few people viewing your post.