I want to write my JSON objects into a csv file in c# I'm using a web api from a windows 8.1 client, I tried this tutorial but "DeserializeXmlNode" seems to be missing, and XmlNode too! http://www.codeproject.com/Tips/565920/Create-CSV-from-JSON-in-Csharp
here's the code i use to get the api response:
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
var server = "http://localhost:1504/api";
var service = System.IO.Path.Combine(server, "PlayerStats");
var playerstat = await GetAsync<IEnumerable<Common.Models.PlayerStat>>(new Uri(service));
}
public async System.Threading.Tasks.Task<T> GetAsync<T>(Uri uri)
{
using (var http = new Windows.Web.Http.HttpClient())
{
http.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await http.GetAsync(uri);
if (response.StatusCode != Windows.Web.Http.HttpStatusCode.Ok)
{
throw new Exception(response.StatusCode.ToString());
}
string json = await response.Content.ReadAsStringAsync();
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);
}
}
}
I'm using System.XML and Newtonsoft.Json but why do I keem missing references, and is there a way to write my objects directy to a csv?
System.Xmland a reference toSystem.Xml.dll