private void okticker_Click(object sender, EventArgs e)
{
string jsonText = "[{ \"channel\":\"ok_btcusd_ticker\", \"data\": {\"buy\":\"2478.3\", \"high\":\"2555\", \"last\":\"2478.51\", \"low\":\"2466\", \"sell\":\"2478.5\", \"timestamp\":\"1411718074965\", \"vol\":\"49,020.30\"} }";
jsonText = jsonText.TrimStart('[');
jsonText = jsonText.TrimEnd(']');
oktickerAll mydata = (oktickerAll)JsonConvert.DeserializeObject(jsonText, typeof(oktickerAll));
}okcoin的api数据用c#解析,花了时间捣鼓,最后就只有几句话
对了,不能遗漏的类
public class oktickerdata
{
public decimal buy { get; set; }
public decimal high { get; set; }
public decimal last { get; set; }
public decimal low { get; set; }
public decimal sell { get; set; }
public Int64 timestamp { get; set; }
public decimal vol { get; set; }
}
public class oktickerAll
{
public string channel { get; set; }
public oktickerdata data { get; set; }
}
本文介绍如何使用C#解析OKCoin交易所API返回的JSON数据。通过实例展示了如何将JSON字符串转换为C#对象,并提供了必要的类定义,以便开发者能够轻松地获取交易对的相关信息。
6567

被折叠的 条评论
为什么被折叠?



