我在Visual Studio 2017中构建UWP应用程序,我想将Office 365 REST API的JSON响应转换为字符串,以在XAML中显示它。C#JSON与Visual Studio 2017的字符串
HttpClient client2 = new HttpClient();
var token2 = await AuthenticationHelper.GetTokenHelperAsync();
client2.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
HttpResponseMessage eventresponse = await client2.GetAsync(new Uri("https://outlook.office.com/api/v2.0/me/calendarview?startDateTime=2017-01-01T00:00:00&endDateTime=2017-04-05T12:00:00"));
我不能得到json.net,我想它是不兼容的。 我试过如下:
using (Stream stream = eventresponse)
{
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
String responseString = reader.ReadToEnd();
}
但我不能转换成HttpResponseMessage System.IO.Stream。
JavaScriptSerializer不可用于UWP应用程序,因为它似乎。
DataContractJsonSerializer无法转换为字符也。
所以即将用尽解决方案/监督我犯的一个重大错误。
'等待eventresponse.Content.ReadAsStringAsync()'? – vossad01
你是什么意思JSON.NET不兼容? – mason