Hi I am trying to create web api that I can call to view all the documents in the MongoDB, now the documents are very large and are heavily nested, I have Managed to return the document but in Json with the headers in XML.
I need to return this entire thing in Json!
This code takes the BsonDocument Product and returns this as Json because without this I get an error:
[JsonIgnore]
public BsonDocument Product { get; set; }
[DataMember]
public string Product
{
get { return Product .ToJson(); }
set { Product = BsonDocument.Parse(value); }
}
Here is a sample of the Document(This is a basic example, the actual document is much larger with deeper levels:
{
"product": {
"Type": "Phone",
"Size": {
"Height": 10,
"Lenght": 5,
"Weight": 30
}
"Make": "Apple"
"Model": {
"Name": "IPhone",
"Range": "4s"
}
}
}
it returns as
<Product>
{"product": {"Type": "Phone","Size": {"Height": 10,"Lenght": 5,"Weight": 30}"Make": "Apple", "Model": {"Name": "IPhone","Range": "4s"}}}
</Product>
How do i fix this?
Like this: