Click or drag to resize
Json.NET

Serialize ExtensionData

 

This sample serializes an object with extension data into JSON.

Sample
Usage
string json = @"{
  'HourlyRate': 150,
  'Hours': 40,
  'TaxRate': 0.125
}";

CustomerInvoice invoice = JsonConvert.DeserializeObject<CustomerInvoice>(json);

// increase tax to 15%
invoice.TaxRate = 0.15m;

string result = JsonConvert.SerializeObject(invoice);
// {
//   "TaxRate": 0.15,
//   "HourlyRate": 150,
//   "Hours": 40
// }