Deserialize from BSON |
This sample deserializes BSON to an object.
public class Event { public string Name { get; set; } public DateTime StartDate { get; set; } }
byte[] data = Convert.FromBase64String("MQAAAAJOYW1lAA8AAABNb3ZpZSBQcmVtaWVyZQAJU3RhcnREYXRlAMDgKWE8AQAAAA=="); MemoryStream ms = new MemoryStream(data); using (BsonReader reader = new BsonReader(ms)) { JsonSerializer serializer = new JsonSerializer(); Event e = serializer.Deserialize<Event>(reader); Console.WriteLine(e.Name); // Movie Premiere }