I use VB.net 2012 and Newtonsoft.Json
Here my code

Public Class Order
        Public Property nb As Integer
        Public Property product As String
        Public Property price As String
 End Class

Public Class Person
        Public Property nb As Integer
        Public Property name As String
        Public Property address As String
 End Class

Dim Orders As New List(Of Order)
Dim ODInfo As Order
ODInfo.nb = 1
ODInfo.product = "Product 1"
ODInfo.price =25
and so on....
Orders.Add(ODInfo)

Dim Persons As New List(Of Person)
Dim PSInfo As Person
PSInfo.nb= 1100
PSInfo.name= "John"
PSInfo.address= "waterstreet 1"
and so on....
Persons.Add(PSInfo)

Dim strProgram As String = Newtonsoft.Json.JsonConvert.SerializeObject(??????, Newtonsoft.Json.Formatting.Indented, serialize)

I want ot create one json file con contains Order- and Person class informatie plus items.

I want to created een json file wat look like this:

{

    "Product": {
        "nb": 1,
        "product": "Product 1",
        "price": 25,

        "nb": 2,
        "product": "Product 2",
        "price": 50
    },

    "person": {
        "nr": 1100,
        "name": "John",
        "address ": "waterstreet 1",

        "nb": 1200,
        "name": "fred",
        "address": "waterstreet 2"
    }
}

How can i do that?

thanks in advance

Assuming your Persons have (one or more) Orders, you probably want to add an Orders (as List(Of Order)) property to your Person class. You will then be able to Json you Persons.
Let me know if my assumption is correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.