I am currently trying to parse the JSON data that I get back from the IEX api, which consists of stocks and their information. The problem I am running into is that depending on which stocks/symbols (ie AAPL, GOOGL etc) you request the keys that are returned change to that symbol. An example of the returned JSON can be seen here: https://api.iextrading.com/1.0/stock/market/batch?symbols=aapl,fb,googl&types=quote,chart&range=1m
To deserialize this I am using JSON.NET and the following classes:
public class Stock {
public quote Quote { get; set;}
public chart Chart { get; set;}
}
public class Root {
public Stock[] Stock;
}
And then I also have classes for the quote and chart objects. I then deserialize the JSON using:
var stocks = JsonConvert.DeserializeObject<Root>(jsonstring);
However, this does not work, but this does work when renaming the 'Stock' class to one of the symbol names, but then only that symbols JSON is parsed. I have no idea what's going on here so any help is greatly appreciated!