Hi Denis,
Here is my "MktBook" class (this is all in Visual Basic):
Code:
Imports Newtonsoft.Json
Imports Newtonsoft.Json.JsonTextReader
Imports Newtonsoft.Json.JsonTextWriter
Imports Newtonsoft.Json.Converters
Public Class MktBook
<JsonProperty(PropertyName:="result")> _
Public Property Result() As List(Of PriceInfo)
End Class
Public Class PriceInfo
<JsonProperty(PropertyName:="marketId")> _
Public Property MarkId() As String
<JsonProperty(PropertyName:="numberOfWinners")> _
Public Property NumberOfWinners() As Integer
<JsonProperty(PropertyName:="numberOfActiveRunners")> _
Public Property NumberOfActiveRunners() As Integer
<JsonProperty(PropertyName:="runners")> _
Public Property Horses() As List(Of RaceHorse)
End Class
Public Class RaceHorse
<JsonProperty(PropertyName:="selectionId")> _
Public Property sId() As Long
<JsonProperty(PropertyName:="status")> _
Public Property Status() As hseStatus
<JsonProperty(PropertyName:="adjustmentFactor")> _
Public Property Adjust() As Double
<JsonProperty(PropertyName:="removalDate")> _
Public Property RemTime() As Date
<JsonProperty(PropertyName:="ex")> _
Public Property Exes() As ExchangeP
<JsonProperty(PropertyName:="totalMatched")> _
Public Property TotMatched() As Double
<JsonProperty(PropertyName:="lastPriceTraded")> _
Public Property LastPriceTraded() As Double?
End Class
<JsonConverter(GetType(StringEnumConverter))> _
Public Enum hseStatus
ACTIVE
WINNER
LOSER
REMOVED_VACANT
REMOVED
End Enum
Public Class ExchangeP
<JsonProperty(PropertyName:="availableToBack")> _
Public Property Backps() As List(Of PSize)
<JsonProperty(PropertyName:="availableToLay")> _
Public Property Layps() As List(Of PSize)
<JsonProperty(PropertyName:="tradedVolume")> _
Public Property TradVol() As List(Of PSize)
End Class
Public Class PSize
<JsonProperty(PropertyName:="price")> _
Public Property p() As Double
<JsonProperty(PropertyName:="size")> _
Public Property s() As Double
End Class
Code:
Dim ListMarketBookResponse As Object = Nothing
Dim strRequest As String = ""
Dim strMarketBook As String = ""
strRequest = "{""jsonrpc"": ""2.0"", ""method"": ""SportsAPING/v1.0/listMarketBook"", ""params"": {""marketIds"":[""" & marketId & """],""priceProjection"":{""priceData"":[""EX_BEST_OFFERS"",""EX_TRADED""],""exBestOffersOverrides"":{""bestPricesDepth"":1}}}, ""id"": 1}"
ListMarketBookResponse = CreateRequest(strKey, strSessTok, strRequest)
strMarketBook = ListMarketBookResponse.ToString
Dim objJson = Newtonsoft.Json.JsonConvert.DeserializeObject(Of MktBook)(strMarketBook)
Dim pHse As Double
Dim sHse As Double
Dim vpHse As Double
Dim vsHse As Double
For y As Integer = 0 To objJson.Result.Count - 1
With objJson.Result(y)
Dim mktRef As String = .MarkId
Dim listHse As List(Of RaceHorse)
listHse = .Horses
For Each Hse As RaceHorse In listHse
With Hse
Dim totvol As Double = .TotMatched
Dim stat As hseStatus = .Status
Dim selRef As Long = .sId
Dim adfactor As Double = .Adjust
Dim exHse As ExchangeP = .Exes
Dim psHse As List(Of PSize) = exHse.Layps
Dim pHse As Double
Dim sHse As Double
If psHse.Count > 0 Then
pHse = psHse.Item(0).p
sHse = psHse.Item(0).s
Else
pHse = Nothing
sHse = Nothing
End If
Dim volHse As List(Of PSize) = exHse.TradVol
If volHse.Count > 0 Then
For Each pitem As PSize In volHse
With pitem
vpHse = pitem.p
vsHse = pitem.s
End With
Next
Else
........
End If
......
End With
......
Next
.......
End With
With regards
Mike


Leave a comment: