Beispiel #1
0
        public static void Test_Deserialize_01()
        {
            //if (trace)
            //    SetTrace();

            Trace.WriteLine("Test_Deserialize_01 : Deserialize()");
            string      json  = "{ value1: \"toto\", value2: 123 }";
            Test_ZValue value = BsonSerializer.Deserialize <Test_ZValue>(json);

            Trace.WriteLine("Test_Deserialize_01 : Serialize()");
            value.zTraceJson();
        }
 public static void Test_Serialize_03()
 {
     Test_ZValue value = new Test_ZValue { value1 = "toto", value2 = 123 };
     using (StringWriter sw = new StringWriter())
     {
         using (BsonWriter bsonWriter = BsonWriter.Create(sw, new JsonWriterSettings { Indent = true, NewLineChars = "\r\n" }))
         {
             BsonSerializer.Serialize(bsonWriter, value);
         }
         Trace.WriteLine(sw.ToString());
     }
 }
Beispiel #3
0
        public static void Test_Serialize_03()
        {
            Test_ZValue value = new Test_ZValue {
                value1 = "toto", value2 = 123
            };

            using (StringWriter sw = new StringWriter())
            {
                using (BsonWriter bsonWriter = BsonWriter.Create(sw, new JsonWriterSettings {
                    Indent = true, NewLineChars = "\r\n"
                }))
                {
                    BsonSerializer.Serialize(bsonWriter, value);
                }
                Trace.WriteLine(sw.ToString());
            }
        }