C# json

 

方式一使用 JavaScriptSerializer

var serializer = new JavaScriptSerializer();
var obj = serializer.Deserialize<Dictionary<string, string>>(data);

string accessToken;
if (!obj.TryGetValue("access_token", out accessToken))
{
  
}
var opentid = obj["openid"];

 

方式二 使用 JObject 需要下载 Newtonsoft.Json

 

JObject jo = (JObject)JsonConvert.DeserializeObject(result);
result = jo.GetValue("token").ToString();

你可能感兴趣的:(json)