下面的JSON需要实现。但我有ItemList
部分问题。需要
把细节放在下面。请帮我们解决。[
Itemlist
JSON:
[
{
"Version":"1.1",
"Topic":{
"new1":"Love",
"new2":"Music"
},
"Doc":{
"Typ":"Book",
"No":"Page"
},
"ItemList":[
{
"SlNo":"1",
"PrdDesc":"Text Book",
"Price":500
}
]
}
]
代码:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Book As List(Of Example) = New List(Of Example)()
Dim el As Example = New Example()
el.Version = 1.1
el.Topic = New Topic
el.Topic.new1 = "Love"
el.Topic.new2 = "Music"
el.Doc = New Doc
el.Doc.Typ = "Book"
el.Doc.No = "Page"
el.ItemList = New List(Of ItemList) '''''''''Here I'm stuck
el.ItemList.SlNo = "1"
el.ItemList.PrdDesc = "Text Book"
el.ItemList.Price = 500
Book.Add(el)
Dim ans As String = JsonConvert.SerializeObject(Book, Formatting.Indented)
File.WriteAllText("d:\Book.json", ans)
End Sub
Public Class ItemList
Public Property SlNo As String
Public Property PrdDesc As String
Public Property Price As String
End Class
Public Class Example
Public Property Version As String
Public Property Topic As Topic
Public Property Doc As Doc
Public Property ItemList As ItemList()
End Class