この JSON の逆シリアル化に問題があります。
JSON は次のようになります。
{
"ticker": {
"high": 91.489,
"low": 88.3,
"avg": 89.8945,
"vol": 233637.9876,
"vol_cur": 2588.09448,
"last": 90.48,
"buy": 90.55,
"sell": 90.48,
"updated": 1372613806,
"server_time": 1372613807
}
}
そして私の機能はこれです:
Private Function Btce(ByVal Address As String) As String
Dim rt As String = ""
Dim out As String
Dim wRequest As WebRequest
Dim wResponse As WebResponse
Dim SR As StreamReader
Dim Time As Date
Time = Now()
wRequest = WebRequest.Create(Address)
wResponse = wRequest.GetResponse
SR = New StreamReader(wResponse.GetResponseStream)
rt = SR.ReadToEnd
SR.Close()
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer
Dim testObj = js.Deserialize(rt, New Object().GetType())
Dim high = testObj("High")
Dim low = testObj("Low")
Dim avg = testObj("Average")
Dim vol = testObj("Volume")
Dim last = testObj("Last")
Dim buy = testObj("Buy")
Dim sell = testObj("Sell")
out = "Data from btc-e.com" + Environment.NewLine
out += (Time) + Environment.NewLine
out += "High: " + Environment.NewLine
out += "Low: " + Environment.NewLine
out += "Average: " + Environment.NewLine
out += "Volume: " + Environment.NewLine
out += "Last: " + Environment.NewLine
out += "Buy: " + Environment.NewLine
out += "Sell: "
Return out
End Function
次に、コンソールでこれを取得します。
タイプ 'System.Collections.Generic.KeyNotFoundException' の未処理の例外が Microsoft.VisualBasic.dll で発生しました 追加情報: 指定されたキーがディクショナリに存在しませんでした。