C#使用Json.Net遍历Json
StringBuilder builder=new StringBuilder(); builder.AppendLine("{"); builder.AppendLine("\"key1\":\"value1\","); builder.AppendLine("\"key2\":\"value2\","); builder.AppendLine("\"key3\":\"value3\","); builder.AppendLine("\"key4\":\"value4\","); builder.AppendLine("\"key5\":\"value5\","); builder.AppendLine("\"key6\":\"value6\""); builder.AppendLine("}"); JObject jObject=JObject.Parse(builder.ToString()); foreach (JProperty jProperty in jObject.Properties()) { Console.WriteLine("key:"+jProperty.Name+" value:"+jProperty.Value); } Console.ReadKey();