C#使用Json.Net遍历Json

 1        StringBuilder builder=new StringBuilder();
 2             builder.AppendLine("{");
 3             builder.AppendLine("\"key1\":\"value1\",");
 4             builder.AppendLine("\"key2\":\"value2\",");
 5             builder.AppendLine("\"key3\":\"value3\",");
 6             builder.AppendLine("\"key4\":\"value4\",");
 7             builder.AppendLine("\"key5\":\"value5\",");
 8             builder.AppendLine("\"key6\":\"value6\"");
 9             builder.AppendLine("}");
10             JObject jObject=JObject.Parse(builder.ToString());
11             foreach (JProperty jProperty in jObject.Properties())
12             {
13                 Console.WriteLine("key:"+jProperty.Name+" value:"+jProperty.Value);
14  
15             }
16             Console.ReadKey();

RT,遍历Json的方法有很多 这只是其中一种。

 

效果图:

 

更多精彩内容,敬请访问:http://www.paohou.net

posted @ 2015-12-28 15:20  晓晨Master  阅读(5326)  评论(0编辑  收藏