我有一个项目,我需要使用json获取数据,然后将其放入数据网格中。获取JSON数据并将其放入变量
这是我得到的数据:
using (WebClient webClient = new WebClient())
{
string email = loginDialog.email;
string password = loginDialog.password;
WebClient http = new WebClient();
http.Headers.Add("Content-Type", "application/json");
http.Headers.Add("OSLC-Core-Version", "2.0");
//Windows login: Email + Password
http.Credentials = new NetworkCredential(email, password);
using(Stream stream = http.OpenRead(stringURL))
{
XmlDocument doc = new XmlDocument();
doc.Load(stream);
string json = JsonConvert.SerializeXmlNode(doc);
//Console.WriteLine(json);
}
}
这里我得到的JSON数据...如何我现在可以把数据(只是优先级)的变量?
// priority =
// BTQStatus =
// implementationDate =
'var json'包含XML或JSON? – aloisdg
您可以反序列化'JSON' /'XML'。 – Sybren
@aloisdg var json包含XML。 – Purger86