我有以下函数来反序列化 json:
Public Sub getDataTable(ByVal json As String)
json = <json>{"TYPE_OF_HANDSET": "4","SMS": [{"DATE": "19.10.2013 13:20","FROM": "SAWA Promo","MESSAGE": "Special offer only for you! Get 300 MB internet + 200 SR Extra Bonus valid for 7 days for only 20 SR. Send 1 to 804097 via SMS. Extra bonus can be used to call and SMS all STC numbers. Happy browsing with SAWA!"},{"DATE": "19.10.2013 13:20","FROM": "SAWA Promo","MESSAGE": "Special offer only for you! Get 300 MB internet + 200 SR Extra Bonus valid for 7 days for only 20 SR. Send 1 to 804097 via SMS. Extra bonus can be used to call and SMS all STC numbers. Happy browsing with SAWA!"}],"DESC": "Samsung GT-I9100","ID_USER": "261"}</json>.Value
Dim data As New DataBck
data = JsonConvert.DeserializeObject(Of DataBck)(json)
handsetType = data.handset
DESC = data.DESC
ID_USER = data.ID_USER
smsDT = data.sms
End Sub
和以下课程:
Public Class DataBck
<System.Runtime.Serialization.DataMember(Name:="TYPE_OF_HANDSET")>
Public handset As Integer
<System.Runtime.Serialization.DataMember(Name:="DESC")>
Public DESC As String
<System.Runtime.Serialization.DataMember(Name:="ID_USER")>
Public ID_USER As Integer
Public sms As DataTable
End Class
当我反序列化 json 时,所有字段名称都正确填充,只有字段名称 TYPE_OF_HANDSET 被填充为空,当我用 HANDSET 替换它时,它被正确填充,尽管 ID_USER 被正确填充而没有删除下划线......
有什么建议么?