title: Convert C# classes to Json
body: <p>How do i serialize multiple c# classes to one json string using . Be able to make the variables in the json data hold values that can change</p>
  
  <p>string outputJSON = JsonConvert.SerializeObject();</p>
  
  <p>i have the following classes </p>
  
  <pre><code> public class Rootobject
      {
      public string Number { get; set; }
          public string RequestedDeviceType { get; set; }
          public string DeliveryMethod { get; set; }
          public Customer Customer { get; set; }
          public Vehicle Vehicle { get; set; }
      }
  
      public class Customer
      {
          public Contacts Contacts { get; set; }
          public string Name { get; set; }
          public string Number { get; set; }
          public bool OverrideData { get; set; }
      }
  
      public class Contacts
      {
          public string FirstName { get; set; }
          public string Name { get; set; }
          public string Email { get; set; }
          public string City { get; set; }
          public string Address { get; set; }
          public string MobilePhone { get; set; }
      }
  
      public class Vehicle
      {
          public string VIN { get; set; }
          public string MakeModelCode { get; set; }
          public string LicensePlate { get; set; }
          public string Make { get; set; }
          public string Model { get; set; }
          public int YearOfInitialRegistration { get; set; }
          public string MotorType { get; set; }
          public bool OverrideData { get; set; }
      }
  
  }
  </code></pre>
  
  <p>They must serialize to the following structure of json structure and i must be able to capture user input and set the values into json file</p>
  
  <pre><code>{
    "Number": "xTest",
    "RequestedDeviceType": "XXXX",
    "DeliveryMethod": "XXXX",
    "Customer": {
      "Contacts": {
  
        "FirstName": "John",
        "Name": "Doe",
        "Email": "mail@demo.com",
        "City": "Harare",
        "Address": "XXXXX",
        "MobilePhone": "00000000"
  
      },
      "Name": "Peter Chaneta",
      "Number": "4567865678",
      "OverrideData": true
    },
    "Vehicle": {
      "VIN": "weryts55444554",
      "MakeModelCode": "34010",
      "LicensePlate": "SS 100 GP",
      "Make": "RANGE ROVER",
      "Model": "SPORT",
      "YearOfInitialRegistration": 2016,
      "MotorType": "Petrol",
      "OverrideData": true
    }
  }
  </code></pre>