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

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

效果图:

C#使用Json.Net遍历Json-LMLPHP

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

05-06 04:38