生成VB.NET类

时间:2017-08-21 05:02:09

标签: json vb.net

我正在使用JSON Utils生成一个类,我遇到了一个问题。我正在使用的JSON字符串:

{
  "type": "champion",
  "version": "7.16.1",
  "data": {
    "1": {
      "title": "the Dark Child",
      "id": 1,
      "key": "Annie",
      "name": "Annie"
    }
  }
}

它生成的类:

Public Class 1
    Public Property title As String
    Public Property id As Integer
    Public Property key As String
    Public Property name As String
End Class

Public Class Data
    Public Property 1 As 1
End Class

Public Class Example
    Public Property type As String
    Public Property version As String
    Public Property data As Data
End Class

问题是我不能说出1级,我仍然试图找到一个解决方案,但还没有运气。有没有解决这个问题?

1 个答案:

答案 0 :(得分:2)

我认为应该改为Dictionary

Public Class Example
    Public Property type As String
    Public Property version As String
    Public Property data As Dictionary(Of String, NumberType)
End Class

Public Class NumberType
    Public Property title As String
    Public Property id As Integer
    Public Property key As String
    Public Property name As String
End Class