Click or drag to resize
Json.NET

Read from BSON

 

This sample reads a JObject from BSON using BsonReader.

Sample
Usage
byte[] data = Convert.FromBase64String("KQAAAAJuYW1lMQAHAAAAdmFsdWUxAAJuYW1lMgAHAAAAdmFsdWUyAAA=");
MemoryStream ms = new MemoryStream(data);

JObject o;
using (BsonReader reader = new BsonReader(ms))
{
    o = (JObject)JToken.ReadFrom(reader);
}

string value = (string)o["name1"];

Console.WriteLine(value);
// value1