using System; using System.Collections.Generic; using System.Linq; namespace JSONTestingAgain { class Program { static void Main(string[] args) { var test = new TestClass { TestGuid = Guid.NewGuid(), TestString = "blah" }; test.TestDictionary.Add("testString", "testStringValue"); test.TestDictionary.Add("testGuid", Guid.NewGuid()); var nancyResult = Nancy(test); var microsoftResult = Microsoft(test); Console.WriteLine(nancyResult); Console.WriteLine(microsoftResult); Console.ReadLine(); } private static TestClass Microsoft(TestClass test) { var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var result = serializer.Serialize(test); var newOne = serializer.Deserialize<TestClass>(result); return newOne; } private static TestClass Nancy(TestClass test) { var serializer = new Nancy.Json.JavaScriptSerializer(); var result = serializer.Serialize(test); var newOne = serializer.Deserialize<TestClass>(result); return newOne; } } public class TestClass { public Guid TestGuid { get; set; } public String TestString { get; set; } public Dictionary<string, object> TestDictionary { get; set; } public TestClass() { this.TestDictionary = new Dictionary<string, object>(); } public override string ToString() { return String.Format( "{0} {1} {2}", TestGuid, TestString, this.TestDictionary.Select(kv => kv.Key.ToString() + ":" + kv.Value.ToString()).Aggregate( (kv1, kv2) => kv1 + "," + kv2)); } } }