【发布时间】:2012-02-25 05:22:27
【问题描述】:
我正在尝试使用 VB.net 反序列化 JSON 字符串,但似乎无法从完成的列表中提取值。这是一个简单的类:
Public Class Personinformation
Private theName As String
Private thePic As String
Public Property Name() As String
Get
Name = theName
End Get
Set(ByVal value As String)
theName = value
End Set
End Property
Public Property Picture() As String
Get
Picture = thePic
End Get
Set(ByVal value As String)
thePic = value
End Set
End Property
End Class
然后在 Page_Load 我插入了以下内容:
Dim JSONstring As String = "[{""Name"":""John"",""Picture"":""mypic.jpg""}]"
Dim json As New JavaScriptSerializer()
Dim outputinfo = json.Deserialize(Of List(Of Personinformation))(JSONstring)
现在我迷路了,因为我似乎无法获得名称/值对。我试过这样做
Response.Write(outputinfo.Item(1))
我被告知“索引超出范围。必须为非负数且小于集合的大小。”
我做错了什么??
【问题讨论】: