我认为我在解析该JSON字符串中的某些信息时遇到问题。 我正在尝试使用下面的代码,但我相信我会发生一些小错误,但该错误未能成功提取我所需要的信息。
我要获取的信息是针对JSON字符串中的这一行的: [{“ symbol”:“ BTC_USD”,“ volumen24hours”:136.53237479,“ ask”:13000,“ bid”:10000,“ lastPrice”:11788}]]
所以我想提取符号,出价并询问。在以下代码中我该怎么办?
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2");
Stream data = client.OpenRead("https://www.bitinka.com/api/apinka/ticker?format=json");
StreamReader reader = new StreamReader(data);
String responseBody = reader.ReadToEnd();
data.Close(); reader.Close();
responseBody = responseBody.ToLower();
dynamic response = JObject.Parse(responseBody);
if (response != null)
{
dynamic usd = response.usd;
if (usd != null)
{
dynamic symbol = usd.symbol; //I want to find the symbol BTC_USD
dynamic bid = usd.bid;
dynamic ask = usd.ask;
if (symbol != null && bid != null && ask != null)
{
MessageBox.Show("This does not find it correctly?");
}
}
}