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; }
}