Hello,
When I try to insert into Mongo a Document, I receive an error for every child of the JsonObject. How can I fix this please? Thank you. The sample code is bellow.
Heres the error:
MongoDB.Bson.BsonSerializationException: An error occurred while serializing the Error property of class DocumentError: An error occurred while serializing the Parent property of class System.Text.Json.Nodes.JsonNode
For every child node until I get
An error occurred while serializing the Parent property of class System.Text.Json.Nodes.JsonNode: Maximum serialization depth exceeded (does the object being serialized have a circular reference?).
Class
[BsonIgnoreExtraElements]
public class DocumentError
{
public JsonObject Error { get; set; }
}
Line of code:
Assuming errorObject is of Type DocumentError with all valid properties set
await Database.GetCollection<DocumentError>("errors").InsertOneAsync(errorObject);