Ejemplo n.º 1
0
        private static void GenerateJsonForAandB(out string jsonA, out string jsonB)
        {
            Console.WriteLine("Begin constructing the original objects. Please ignore trace information until I'm done.");

            // set all parameters to false to produce pure JSON
            fastJSON.JSON.Instance.Parameters = new JSONParameters {
                EnableAnonymousTypes = false, IgnoreCaseOnDeserialize = false, SerializeNullValues = false, ShowReadOnlyProperties = false, UseExtensions = false, UseFastGuid = false, UseOptimizedDatasetSchema = false, UseUTCDateTime = false, UsingGlobalTypes = false
            };

            var a = new ConcurrentClassA {
                PayloadA = new PayloadA()
            };
            var b = new ConcurrentClassB {
                PayloadB = new PayloadB()
            };

            // A is serialized with extensions and global types
            jsonA = JSON.Instance.ToJSON(a, new JSONParameters {
                EnableAnonymousTypes = false, IgnoreCaseOnDeserialize = false, SerializeNullValues = false, ShowReadOnlyProperties = false, UseExtensions = true, UseFastGuid = false, UseOptimizedDatasetSchema = false, UseUTCDateTime = false, UsingGlobalTypes = true
            });
            // B is serialized using the above defaults
            jsonB = JSON.Instance.ToJSON(b);

            Console.WriteLine("Ok, I'm done constructing the objects. Below is the generated json. Trace messages that follow below are the result of deserialization and critical for understanding the timing.");
            Console.WriteLine(jsonA);
            Console.WriteLine(jsonB);
        }
Ejemplo n.º 2
0
 public void NullOutput()
 {
     var c = new ConcurrentClassA ();
     var s = JSON.ToJSON (c, new JSONParameters { UseExtensions = false, SerializeNullValues = false });
     Console.WriteLine (JSON.Beautify (s));
     Assert.AreEqual (false, s.Contains (",")); // should not have a comma
 }
Ejemplo n.º 3
0
        void GenerateJsonForAandB(out string jsonA, out string jsonB)
        {
            Console.WriteLine("Begin constructing the original objects. Please ignore trace information until I'm done.");


            var a = new ConcurrentClassA {
                PayloadA = new PayloadA()
            };
            var b = new ConcurrentClassB {
                PayloadB = new PayloadB()
            };

            // A is serialized with extensions and global types
            jsonA = Json.ToJson(a, new SerializationManager {
                EnableAnonymousTypes = false, SerializeNullValues = false, SerializeReadOnlyProperties = false, UseExtensions = true, UseFastGuid = false, UseOptimizedDatasetSchema = false, UseUniversalTime = false
            });
            // B is serialized using below settings
            // set all parameters to false to produce pure JSON
            jsonB = Json.ToJson(b, new SerializationManager {
                EnableAnonymousTypes = false, SerializeNullValues = false, SerializeReadOnlyProperties = false, UseExtensions = false, UseFastGuid = false, UseOptimizedDatasetSchema = false, UseUniversalTime = false
            });

            Console.WriteLine("Ok, I'm done constructing the objects. Below is the generated json. Trace messages that follow below are the result of deserialization and critical for understanding the timing.");
            Console.WriteLine(jsonA);
            Console.WriteLine(jsonB);
        }
Ejemplo n.º 4
0
        public static void NullOutput()
        {
            var c = new ConcurrentClassA();
            var s = fastJSON.JSON.Instance.ToJSON(c, new JSONParameters {
                UseExtensions = false
            });

            Console.WriteLine(fastJSON.JSON.Instance.Beautify(s));
            Assert.AreEqual(false, s.Contains(",")); // should not have a comma
        }
Ejemplo n.º 5
0
        public void NullOutput()
        {
            var c = new ConcurrentClassA();
            var s = JSON.ToJSON(c, new JSONParameters {
                UseExtensions = false, SerializeNullValues = false
            });

            Console.WriteLine(JSON.Beautify(s));
            Assert.AreEqual(false, s.Contains(","));               // should not have a comma
        }
Ejemplo n.º 6
0
        public void NullOutput()
        {
            var c = new ConcurrentClassA();
            var s = Json.ToJson(c, new SerializationManager {
                UseExtensions = false, SerializeNullValues = false
            });

            Console.WriteLine(Json.Beautify(s));
            Assert.AreEqual(false, s.Contains(","));               // should not have a comma
        }
Ejemplo n.º 7
0
        void GenerateJsonForAandB(out string jsonA, out string jsonB)
        {
            Console.WriteLine ("Begin constructing the original objects. Please ignore trace information until I'm done.");

            // set all parameters to false to produce pure JSON
            JSON.Parameters = new JSONParameters { EnableAnonymousTypes = false, SerializeNullValues = false, ShowReadOnlyProperties = false, UseExtensions = false, UseFastGuid = false, UseOptimizedDatasetSchema = false, UseUTCDateTime = false, UsingGlobalTypes = false };

            var a = new ConcurrentClassA { PayloadA = new PayloadA () };
            var b = new ConcurrentClassB { PayloadB = new PayloadB () };

            // A is serialized with extensions and global types
            jsonA = JSON.ToJSON (a, new JSONParameters { EnableAnonymousTypes = false, SerializeNullValues = false, ShowReadOnlyProperties = false, UseExtensions = true, UseFastGuid = false, UseOptimizedDatasetSchema = false, UseUTCDateTime = false, UsingGlobalTypes = true });
            // B is serialized using the above defaults
            jsonB = JSON.ToJSON (b);

            Console.WriteLine ("Ok, I'm done constructing the objects. Below is the generated json. Trace messages that follow below are the result of deserialization and critical for understanding the timing.");
            Console.WriteLine (jsonA);
            Console.WriteLine (jsonB);
        }