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); }
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); }
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); }