如何使用JSON.NET解析JSON子代?

时间:2014-08-18 03:13:06

标签: json vb.net json.net

我正在尝试从JSON中获取textures: […]中的结果 http://t0.rbxcdn.com/ca063a6bab4e145de481384a8a62d64f并将其显示在列表框中。

我有这段代码:

Public Class ReturnObject
    Public Property Url As String
    Public Property textures As String
    Public Property obj As String
    Public Property mtl As String
    Public Property Final As Boolean
End Class
Dim input2 As String = obj.Text
Dim json2 As ReturnObject = JsonConvert.DeserializeObject(Of ReturnObject)(input2)
obj.Text = HttpGet("http://www.roblox.com/thumbnail/resolve-hash/" + json2.obj)
mtl.Text = HttpGet("http://www.roblox.com/thumbnail/resolve-hash/" + json2.mtl)

但是我收到了错误

  

读取字符串时出错。意外的令牌:StartArray。路径'纹理',   第1行,第313位。

1 个答案:

答案 0 :(得分:0)

textures是JSON中的一个数组,包含一个字符串(请注意括号*):

"textures":["bff5714f0b959385663b1fe030b87064"]

你可以在你的班级结构中反映出来(注意方括号**):

Public Class ReturnObject
    Public Property Url As String
    Public Property textures As String()
    Public Property obj As String
    Public Property mtl As String
    Public Property Final As Boolean
End Class

*他们是方括号
**他们是括号