BsonValue bsonValue = BsonValue.Create("Hello, world!"); string jsonString = bsonValue.ToJson(); Console.WriteLine(jsonString);
BsonArray bsonArray = new BsonArray { 1, 2, 3 }; string json = bsonArray.ToJson(); Console.WriteLine(json);This code creates a BsonArray containing the values 1, 2, and 3. It then converts the array to a JSON formatted string using the ToJson method. The resulting string will be `[1, 2, 3]`. Both of these examples use the MongoDB C# driver, which can be found at https://www.nuget.org/packages/MongoDB.Driver/.