I wanted to convert a json into an array but I get "application went to break mode" when I try debugging mode and the program just freezes down if I try to run it.
I used the answer of Convert json to a C# array? but something went wrong.
Could you help me to find the cause of the error?
{
public class MarketHistory
{
public string Date { get; set; }
public string Order_Count { get; set; }
public string Volume { get; set; }
public string Highest { get; set; }
public string Avarage { get; set; }
public string Lowest { get; set; }
}
class Program
{
public static string DownloadString(string address)
{
WebClient client = new WebClient();
string reply = client.DownloadString(address);
return reply;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
string url = "https://esi.tech.ccp.is/latest/markets/10000002/history/?datasource=tranquility&type_id=42";
var json = DownloadString(url);
JavaScriptSerializer js = new JavaScriptSerializer();
MarketHistory[] marketHistories = js.Deserialize<MarketHistory[]>(json);
Console.ReadKey();
}
}
}
The json:
[
{
"date": "2016-11-01",
"order_count": 24,
"volume": 275,
"highest": 28.17,
"average": 28.15,
"lowest": 28
},
First fix:
{
public class MarketHistory
{
public string date { get; set; }
public string order_count { get; set; }
public string volume { get; set; }
public string highest { get; set; }
public string avarage { get; set; }
public string lowest { get; set; }
}
class Program
{
public static string DownloadString(string address)
{
WebClient client = new WebClient();
string reply = client.DownloadString(address);
return reply;
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
string url = "https://esi.tech.ccp.is/latest/markets/10000002/history/?datasource=tranquility&type_id=42";
var json = DownloadString(url);
JavaScriptSerializer js = new JavaScriptSerializer();
MarketHistory[] marketHistories = js.Deserialize<MarketHistory[]>(json);
Console.ReadKey();
}
}
}
I added the reference, any idea why can I get the
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. at Eve_console_app.Program.Main(String[] args)
error?