HttpResponse as string - 将数字转换为字母
HttpResponse as string - turning numbers into letters
我正在连接到网络 API 并要求回复,但我的回复显示不正确,如 "high":4.166e-5,而我期待的是 0.00004166 之类的数字我问的是 BTC 的市场价格,我认为这是一个 32 位整数问题,但它是一个字符串,所以我丢失了。对不起,如果我没有很好地解释这一点。
这是我正在阅读的回复:
`{"date":1493626200,"high":4.166e-5,"low":4.158e-5,"open":4.166e-5,"close":4.158e-5,"volume":0.05681982,"quoteVolume":1364.65936831,"weightedAverage":4.163e-5}]
这就是我格式化 httpresponse 的方式
` Dim response As HttpResponseMessage = client.PostAsync(privUrl, myContent).Result
If response.IsSuccessStatusCode Then
Dim json As String = response.Content.ReadAsStringAsync().Result
Return json
End If
然后用这个反序列化
Dim json As String = JsonConvert.DeserializeObject(responseFromServer).ToString()
编辑***
现在我正在使用 EuX0 示例,但仍然出现错误
无法将当前 JSON 数组(例如 [1,2,3])反序列化为类型 'class_test.FormatOutputData',因为该类型需要一个 JSON 对象
Dim responseFromServer As String = apiSettings.TradingApi("returnTradeHistory¤cyPair=BTC_XRP")
TextBox1.AppendText(responseFromServer) 'so i can see whats coming in
Dim jsonString As String = responseFromServer
**Dim obj As FormatOutputData = JsonConvert.DeserializeObject(Of FormatOutputData)(jsonString)**
obj.outputValues()
这是一个完整的JSON输出[{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]jsonString: [{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]
Imports Newtonsoft.Json
Module Module1
Sub Main()
Dim jsonString As String = My.Computer.FileSystem.ReadAllText("C:.txt")
Console.WriteLine(String.Format("jsonString: {0}{1}", jsonString, vbNewLine))
Dim objarray As New List(Of FormatOutputData)
objarray.AddRange(JsonConvert.DeserializeObject(Of FormatOutputData())(jsonString))
For Each item As FormatOutputData In objarray
item.outputValues()
Next
Console.ReadLine()
End Sub
Private Class FormatOutputData
Public globalTradeID As Long
Public tradeID As Long
Public [date] As String
Public rate As Decimal
Public amount As Decimal
Public total As Decimal
Public fee As Decimal
Public orderNumber As String
Public type As String
Public category As String
Public Sub outputValues()
Console.WriteLine(String.Format("globalTradeID: {1}{0}tradeID: {2}{0}date: {3}{0}rate: {4}{0}amount: {5}{0}total: {6}{0}fee: {7}{0}orderNumber: {8}{0}type: {9}{0}category: {10}{0}",
vbNewLine, globalTradeID, tradeID, [date], rate, amount, total, fee, orderNumber, type, category))
End Sub
End Class
End Module
输出示例:
jsonString: [{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]
globalTradeID: 116229026
tradeID: 4728521
date: 2017-05-01 11:21:43
rate: 0,00004113
amount: 6118,34548991
total: 0,25164754
fee: 0,00150000
orderNumber: 40272934869
type: buy
category: exchange
globalTradeID: 116227160
tradeID: 4728350
date: 2017-05-01 11:17:51
rate: 0,00004115
amount: 4,08198005
total: 0,00016797
fee: 0,00250000
orderNumber: 40271626179
type: buy
category: settlement
编辑 2:
Sub Main()
Dim nestedJsonClass As NestedJson = JsonConvert.DeserializeObject(Of NestedJson)(jsonString)
Console.WriteLine(String.Format("Order number: {0}", nestedJsonClass.orderNumber))
Console.WriteLine(String.Format(" ->:amount: {0}", nestedJsonClass.resultingTrades.Item(0).amount))
Console.WriteLine(String.Format(" ->:date: {0}", nestedJsonClass.resultingTrades.Item(0).Date))
End Sub
Private Class NestedJson
Public orderNumber As ULong
Public resultingTrades As New List(Of Nested)
End Class
Private Class Nested
Public amount As Decimal
Public [Date] As String
Public rate As Decimal
Public total As Decimal
Public tradeID As Long
Public type As String
End Class
编辑 3:
Sub Main()
Dim jsonInput As String = My.Computer.FileSystem.ReadAllText("C:.txt")
Dim whatEver As topLevelObject = JsonConvert.DeserializeObject(Of topLevelObject)(jsonInput)
Console.WriteLine(whatEver.asks(0)(0))
Console.WriteLine(whatEver.asks(0)(1))
Console.ReadLine()
End Sub
Public Class topLevelObject
Public asks() As List(Of Object)
Public bids() As List(Of Object)
Public isFrozen As String
Public seq As Integer
End Class
我正在连接到网络 API 并要求回复,但我的回复显示不正确,如 "high":4.166e-5,而我期待的是 0.00004166 之类的数字我问的是 BTC 的市场价格,我认为这是一个 32 位整数问题,但它是一个字符串,所以我丢失了。对不起,如果我没有很好地解释这一点。
这是我正在阅读的回复:
`{"date":1493626200,"high":4.166e-5,"low":4.158e-5,"open":4.166e-5,"close":4.158e-5,"volume":0.05681982,"quoteVolume":1364.65936831,"weightedAverage":4.163e-5}]
这就是我格式化 httpresponse 的方式
` Dim response As HttpResponseMessage = client.PostAsync(privUrl, myContent).Result
If response.IsSuccessStatusCode Then
Dim json As String = response.Content.ReadAsStringAsync().Result
Return json
End If
然后用这个反序列化
Dim json As String = JsonConvert.DeserializeObject(responseFromServer).ToString()
编辑***
现在我正在使用 EuX0 示例,但仍然出现错误 无法将当前 JSON 数组(例如 [1,2,3])反序列化为类型 'class_test.FormatOutputData',因为该类型需要一个 JSON 对象
Dim responseFromServer As String = apiSettings.TradingApi("returnTradeHistory¤cyPair=BTC_XRP")
TextBox1.AppendText(responseFromServer) 'so i can see whats coming in
Dim jsonString As String = responseFromServer
**Dim obj As FormatOutputData = JsonConvert.DeserializeObject(Of FormatOutputData)(jsonString)**
obj.outputValues()
这是一个完整的JSON输出[{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]jsonString: [{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]
Imports Newtonsoft.Json
Module Module1
Sub Main()
Dim jsonString As String = My.Computer.FileSystem.ReadAllText("C:.txt")
Console.WriteLine(String.Format("jsonString: {0}{1}", jsonString, vbNewLine))
Dim objarray As New List(Of FormatOutputData)
objarray.AddRange(JsonConvert.DeserializeObject(Of FormatOutputData())(jsonString))
For Each item As FormatOutputData In objarray
item.outputValues()
Next
Console.ReadLine()
End Sub
Private Class FormatOutputData
Public globalTradeID As Long
Public tradeID As Long
Public [date] As String
Public rate As Decimal
Public amount As Decimal
Public total As Decimal
Public fee As Decimal
Public orderNumber As String
Public type As String
Public category As String
Public Sub outputValues()
Console.WriteLine(String.Format("globalTradeID: {1}{0}tradeID: {2}{0}date: {3}{0}rate: {4}{0}amount: {5}{0}total: {6}{0}fee: {7}{0}orderNumber: {8}{0}type: {9}{0}category: {10}{0}",
vbNewLine, globalTradeID, tradeID, [date], rate, amount, total, fee, orderNumber, type, category))
End Sub
End Class
End Module
输出示例:
jsonString: [{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]
globalTradeID: 116229026
tradeID: 4728521
date: 2017-05-01 11:21:43
rate: 0,00004113
amount: 6118,34548991
total: 0,25164754
fee: 0,00150000
orderNumber: 40272934869
type: buy
category: exchange
globalTradeID: 116227160
tradeID: 4728350
date: 2017-05-01 11:17:51
rate: 0,00004115
amount: 4,08198005
total: 0,00016797
fee: 0,00250000
orderNumber: 40271626179
type: buy
category: settlement
编辑 2:
Sub Main()
Dim nestedJsonClass As NestedJson = JsonConvert.DeserializeObject(Of NestedJson)(jsonString)
Console.WriteLine(String.Format("Order number: {0}", nestedJsonClass.orderNumber))
Console.WriteLine(String.Format(" ->:amount: {0}", nestedJsonClass.resultingTrades.Item(0).amount))
Console.WriteLine(String.Format(" ->:date: {0}", nestedJsonClass.resultingTrades.Item(0).Date))
End Sub
Private Class NestedJson
Public orderNumber As ULong
Public resultingTrades As New List(Of Nested)
End Class
Private Class Nested
Public amount As Decimal
Public [Date] As String
Public rate As Decimal
Public total As Decimal
Public tradeID As Long
Public type As String
End Class
编辑 3:
Sub Main()
Dim jsonInput As String = My.Computer.FileSystem.ReadAllText("C:.txt")
Dim whatEver As topLevelObject = JsonConvert.DeserializeObject(Of topLevelObject)(jsonInput)
Console.WriteLine(whatEver.asks(0)(0))
Console.WriteLine(whatEver.asks(0)(1))
Console.ReadLine()
End Sub
Public Class topLevelObject
Public asks() As List(Of Object)
Public bids() As List(Of Object)
Public isFrozen As String
Public seq As Integer
End Class