Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to create a json string :
{"materials": [{""Article"":"53424","Description":"blabla","Price":25,"Unit":"3"}]}

but I only get
[{""Article"":"53424","Description":"blabla","Price":25,"Unit":"3"}]


How do I include the parent {"materials": into my string?

What I have so far:

VB.NET
Dim NewMaterial As New List(Of materialdetails)()
        NieuweMaterial .Add(New materialdetailsWith {.Article = "45147", .Description = "Dbla", .Price= 50, .Unit = "dfdk"}) 

        Dim materialen As New List(Of materialen)()



VB.NET
Public Class materialdetails
    Public Property Article As String
    Public Property Description As String
    Public Property Price As Decimal
    Public Property Unit As String
End Class
Public Class Parent
    Public Property parenttitle  As String
    Public Property materialdetails As List(Of materialdetails)()

End Class


As you can see I am struggling to get the parent of the parenttitle in the string. Please help with a simple example on how you would do this?
Thanks for any answer.
Posted
Updated 9-Jan-16 1:24am
v3
Comments
Maciej Los 9-Jan-16 7:21am    
What method do you use to serialize data?
Inge van Gemert 9-Jan-16 12:11pm    
The javascriptserializer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900