var jObject = Newtonsoft.Json.Linq.JObject.Parse(ids);
foreach (KeyValuePair<string, JToken> keyValuePair in jObject)
{
Debug.WriteLine(keyValuePair.Key);
}
或者
string areajson="[{"251139":"university_of_bath"},{"253980":"\u6cd5\u56fd\u5170\u65af\u7ba1\u7406\u5b66\u9662"},{"250362":"\u590d\u65e6\u5b66\u9662"}]";
JArray ja = JArray.Parse(areajson);
if (ja != null)
{
foreach (JObject jo in ja)
{
Dictionary<string,string> values = JsonConvert.DeserializeObject<Dictionary<string,string>>(jo.ToString());
foreach (string key in values.Keys)
{
Response.Write(ja.Count+" key: "+key + " " + values[key] + "<br/>");//key是属性名,values[key]是属性的值}
}
}
}
Tags:C#