static void JSON2() { string JSONString = "{\" Array\":[ \"字符串\", false], \"number\": " + "\n\n\n\t\r123, \"dgfsrfe\": null}"; Console.WriteLine($"Input: {JSONString}"); ReadJSON readJSON = new ReadJSON(); Dictionary <string, object> obj = readJSON.Parser(JSONString); Stopwatch sw = new Stopwatch(); sw.Start(); readJSON.Parser(JSONString); sw.Stop(); Console.WriteLine($"所用时间:{sw.ElapsedMilliseconds} ms"); Console.WriteLine("{"); Console.WriteLine("\t\" Array\": ["); Console.WriteLine($"\t\t\"{((List<object>)obj[" Array"])[0]}\","); Console.WriteLine($"\t\t{((List<object>)obj[" Array"])[1]},"); Console.WriteLine("\t],"); Console.WriteLine($"\t\"number\":{obj["number"]},"); Console.WriteLine($"\t\"dgfsrfe\":{obj["dgfsrfe"] ?? "null"}"); Console.WriteLine("}"); Console.WriteLine($"转换为字符串:{WriteJSON.Write(obj)}"); sw.Start(); for (int i = 0; i < 100; ++i) { readJSON.Parser(JSONString); } sw.Stop(); Console.WriteLine($"一百次所用时间:{sw.ElapsedMilliseconds} ms"); Console.ReadKey(); }
static void JSON3() { string JSONString = "[true]"; Console.WriteLine($"Input: {JSONString}"); ReadJSON readJSON = new ReadJSON(); List <object> obj = readJSON.Parser(JSONString); Stopwatch sw = new Stopwatch(); sw.Start(); readJSON.Parser(JSONString); sw.Stop(); Console.WriteLine($"所用时间:{sw.ElapsedMilliseconds} ms"); Console.WriteLine("["); Console.WriteLine($"\t{obj[0]}"); Console.WriteLine("]"); Console.WriteLine($"转换为字符串:{WriteJSON.Write(obj)}"); sw.Start(); for (int i = 0; i < 100; ++i) { readJSON.Parser(JSONString); } sw.Stop(); Console.WriteLine($"一百次所用时间:{sw.ElapsedMilliseconds} ms"); Console.ReadKey(); }
static void JSON4() { string JSONString = "{\"st\tring\": \"\t\t\\t\u1234\"}"; Console.WriteLine($"Input: {JSONString}"); ReadJSON readJSON = new ReadJSON(); Dictionary <string, object> obj = readJSON.Parser(JSONString); Stopwatch sw = new Stopwatch(); sw.Start(); readJSON.Parser(JSONString); sw.Stop(); Console.WriteLine($"所用时间:{sw.ElapsedMilliseconds} ms"); Console.WriteLine("{"); Console.WriteLine($"\t\"st\tring\":\"{obj["st\tring"]}\""); Console.WriteLine("}"); Console.WriteLine($"转换为字符串:{WriteJSON.Write(obj)}"); sw.Start(); for (int i = 0; i < 100; ++i) { readJSON.Parser(JSONString); } sw.Stop(); Console.WriteLine($"一百次所用时间:{sw.ElapsedMilliseconds} ms"); Console.ReadKey(); }