I'm trying to write a trading bot as a learning experience (don't worry, I won't use it). I am trying to deserialize the incoming data with no luck. It's my first time working with json in C# but I have done so in other languages, certainly not very good at it though.
I created a class that looks like this:
public class Coin
{
public string symbol { get; set; }
public double price {get;set;}
}
I am fetching and reading the data like this:
using (WebClient w = new WebClient())
{
try
{
var json = w.DownloadString("https://api.binance.com/api/v3/ticker/price");
int length = json.Length;
string newJson = json.Substring(1, length-2);
//had to create new string because having [] made it crash
Coin coin = JsonConvert.DeserializeObject<Coin>(newJson);
Console.Write(coin); // this does not print anything
}catch(JsonReaderException e){}
}
Incoming data looks like this (or just follow the link):
{"symbol":"ETHBTC","price":"0.07190100"},{"symbol":"LTCBTC","price":"0.01298100"}
Now, I'm trying to only get one of them, but I am getting all. First of all I'm guessing there's something wrong with my Coin class and second I don't know how to access just one of them.
Thanks