我是这个话题的新手,基本上我有这个 JSON 字符串:
"{"payChannleResult":{"lastestPayChannel":"","supportedPayChannelList":{"supportTopPayChannel":[{"name":"FastPay","cashierCode":"CREDITCARD","supportSecPayChannelList":{"supportSecPayChannel":[{"name":"BankA","cashierCode":"CREDITCARD_A"},{"name":"BankB","cashierCode":"CREDITCARD_B"},
{"name":"BankE","cashierCode":"CREDITCARD_E"},
{"name":"More","cashierCode":"CREDITCARD"}]}},
{"name":"Credits","cashierCode":"DEBITCARD","supportSecPayChannelList":{"supportSecPayChannel":[{"name":"BankF","cashierCode":"DEBITCARD_F"},
{"name":"BankI","cashierCode":"DEBITCARD_I"},
{"name":"More","cashierCode":"DEBITCARD"}]}}]}}}"
我为此开设了课程:
<Serializable()> Public Class RootObject
Private _payChannelResult As PayChannleResult
Public Property payChannleResult() As PayChannleResult
Get
Return _payChannelResult
End Get
Set(ByVal value As PayChannleResult)
_payChannelResult = value
End Set
End Property
End Class
<Serializable()> Public Class PayChannleResult
Private _lastestPayChannel As String 'LastestPayChannel
Private _supportedPayChannelList As SupportedPayChannelList
Public Property lastestPayChannel() As String
Get
Return _lastestPayChannel
End Get
Set(ByVal value As String)
_lastestPayChannel = value
End Set
End Property
Public Property supportedPayChannelList() As SupportedPayChannelList
Get
Return _supportedPayChannelList
End Get
Set(ByVal value As SupportedPayChannelList)
_supportedPayChannelList = value
End Set
End Property
End Class
<Serializable()> Public Class SupportedPayChannelList
Private _supportTopPayChannel As SupportTopPayChannel
Public Property supportTopPayChannel() As SupportTopPayChannel
Get
Return _supportTopPayChannel
End Get
Set(ByVal value As SupportTopPayChannel)
_supportTopPayChannel = value
End Set
End Property
End Class
<Serializable()> Public Class SupportTopPayChannel
Private _name As String
Private _cashierCode As String
Private _supportSecPayChannelList As SupportSecPayChannelList
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property cashierCode() As String
Get
Return _cashierCode
End Get
Set(ByVal value As String)
_cashierCode = value
End Set
End Property
Public Property supportSecPayChannelList() As SupportSecPayChannelList
Get
Return _supportSecPayChannelList
End Get
Set(ByVal value As SupportSecPayChannelList)
_supportSecPayChannelList = value
End Set
End Property
End Class
<Serializable()> Public Class SupportSecPayChannelList
Private _supportSecPayChannel As List(Of SupportSecPayChannel)
Public Property supportSecPayChannel() As List(Of SupportSecPayChannel)
Get
Return _supportSecPayChannel
End Get
Set(ByVal value As List(Of SupportSecPayChannel))
_supportSecPayChannel = value
End Set
End Property
End Class
<Serializable()> Public Class SupportSecPayChannel
Private _name As String
Private _cashierCode As String
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property cashierCode() As String
Get
Return _cashierCode
End Get
Set(ByVal value As String)
_cashierCode = value
End Set
End Property
End Class
<Serializable()> Public Class LastestPayChannel
Private _name As String
Private _cashierCode As String
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property cashierCode() As String
Get
Return _cashierCode
End Get
Set(ByVal value As String)
_cashierCode = value
End Set
End Property
End Class
最后这就是我调用解串器函数的方式:
Dim seriliazer As JavaScriptSerializer = New JavaScriptSerializer
Dim p As RootObject = seriliazer.Deserialize(Of RootObject)(strJson)
但它给出了错误:不支持类型“SupportTopPayChannel”用于数组的反序列化。
请帮帮我,非常感谢!!!!!!!