I would like to convert string "{{1,2,3},{4,5,6},{7,8,9}}" to an array. Can I do that?
I am getting data from binance.com:
string str = Client.DownloadString("https://" + $"api.binance.com/api/v3/klines?symbol={symbol}&interval={interval}&startTime={startTime}&endTime={endTime}&limit={limit}");
And the return is something like:
[[1502942400000,"4261.48000000","4261.48000000","4261.48000000","4261.48000000","1.77518300",1502942459999,"7564.90685084",3,"0.07518300","320.39085084","7960.54017996"],[1502942460000,"4261.48000000","4261.48000000","4261.48000000","4261.48000000","0.00000000",1502942519999,"0.00000000",0,"0.00000000","0.00000000","7960.45262989"]]
I would like to convert this string to an array. I changed all '[' and ']' to '{' and '}'. Can I convert this type of string to an array?
Thanks
That string is in Json format. Use the Json.NET library to deserialize it:
string str = "[[1502942400000,\"4261.48000000\",\"4261.48000000\",\"4261.48000000\",\"4261.48000000\",\"1.77518300\",1502942459999,\"7564.90685084\",3,\"0.07518300\",\"320.39085084\",\"7960.54017996\"],[1502942460000,\"4261.48000000\",\"4261.48000000\",\"4261.48000000\",\"4261.48000000\",\"0.00000000\",1502942519999,\"0.00000000\",0,\"0.00000000\",\"0.00000000\",\"7960.45262989\"]]";
double[][] res = JsonConvert.DeserializeObject<double[][]>(str);