Wondering if you could help me create a VB.Net class into which I can deserialize the following JSON response:
{
"id":86,
"name":"Tom",
"likes":
{
"actors":[
["Clooney",2,30,4],
["Hanks",104,15,1]
]
},
"code":8
}
I have the following:
Class mLikes
Public actors As IList(Of IList(Of String))
end Class
and
Class Player
<JsonProperty(PropertyName:="id")>
Public Id As Integer
<JsonProperty(PropertyName:="name")>
Public Name As String
<JsonProperty(PropertyName:="likes")>
Public Likes As mLikes
<JsonProperty(PropertyName:="code")>
Public Code As Integer
End Class
I am using Newtonsoft.Json to deserialize:
Result = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Player)(jsonResponse)
If I know that the actors elements always follow the same format -
Class Actor
Public Name as String
Public NumberOfMovies as Integer
Public NumberOfAwards as Integer
Public NumberOfTVshows as Integer
End Class
Is there a way I can parse the JSON response so that Player.Likes.Actors is a List(Of Actor) instead of a List(Of List(Of String)) which is what I have now?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…