Class for Deserializing JSON Navigation Menu response

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahn
    Junior Member
    • Jul 2011
    • 12

    #1

    Class for Deserializing JSON Navigation Menu response

    Hi,

    Is any code available for deserializing the JSON Navigation Menu response? Trying to create a class for deserializing the response is very tricky because the expected child class is not fixed at every nested point. For example, an Event Type might have as a child a GROUP and/or an EVENT and/or a RACE.

    Thanking you in advance,

    Panos Kourtesis
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    I tried this last year. Someone suggested improvements (on the forum somewhere, perhaps in the very long VB.NET thread under Exchange API), but at the time I was using a Javascript function to convert between JSON and .NET class, and even though I downloaded the navigation file, the conversion never worked. Perhaps it couldn't handle the amount of data, which was typically 4-5MB.

    I changed to using the NewtonSoft converter, but I haven't tried it with the navigation file because the navigation file wasn't needed for my program.

    These are the classes I had, but I've no idea whether they'll work for you.

    Code:
     Class NavRoot
            Dim children() As NavItem
            Dim type As String
            Dim name As String
            Dim id As String
        End Class
        Class NavItem
            Dim children() As NavItem
            Dim type As String
            Dim name As String
            Dim id As String
            Dim exchangeId As String
            Dim countryCode As String
            Dim venue As String
            Dim marketType As String
            Dim marketStartTime As String
            Dim startTime As String
            Dim numberOfWinners As String
        End Class
    I'm not at all convinced that children() will always be NavItem. I had tried just defining them as Object.

    Comment

    • ahn
      Junior Member
      • Jul 2011
      • 12

      #3
      Originally posted by jabe View Post
      I tried this last year. Someone suggested improvements (on the forum somewhere, perhaps in the very long VB.NET thread under Exchange API), but at the time I was using a Javascript function to convert between JSON and .NET class, and even though I downloaded the navigation file, the conversion never worked. Perhaps it couldn't handle the amount of data, which was typically 4-5MB.

      I changed to using the NewtonSoft converter, but I haven't tried it with the navigation file because the navigation file wasn't needed for my program.

      These are the classes I had, but I've no idea whether they'll work for you.

      Code:
       Class NavRoot
              Dim children() As NavItem
              Dim type As String
              Dim name As String
              Dim id As String
          End Class
          Class NavItem
              Dim children() As NavItem
              Dim type As String
              Dim name As String
              Dim id As String
              Dim exchangeId As String
              Dim countryCode As String
              Dim venue As String
              Dim marketType As String
              Dim marketStartTime As String
              Dim startTime As String
              Dim numberOfWinners As String
          End Class
      I'm not at all convinced that children() will always be NavItem. I had tried just defining them as Object.
      Unfortunatelly it does not work. In Api v6 we had the parentId field and we could populate the menu treeview on demand, instead of getting the whole universe of events and markets. Instead of calling the menu.json end point is there another way of creating a menu tree view?

      Comment

      • jabe
        Senior Member
        • Dec 2014
        • 705

        #4
        One for the Betfair people. As I said, I downloaded the data but couldn't turn it into usable data. Perhaps someone else succeeded.

        Comment

        Working...
        X