Example #1
0
        public void Document_ImplicitConvert_Test()
        {
            var obj = new Dictionary <string, object>()
            {
                { "int", 123 },
                { "arr", new object[] { 3.0, 2, 1, "zero", false } },
                { "doc", new Dictionary <string, object>()
                  {
                      { "a", "a" },
                      { "b", new int[] { 0 } },
                  } }
            };

            var doc = BsonValue.FromObject(obj);

            var json = JsonSerializer.Serialize(doc);

            Assert.AreEqual("{\"int\":123,\"arr\":[3.0,2,1,\"zero\",false],\"doc\":{\"a\":\"a\",\"b\":[0]}}", json);
        }