Click or drag to resize
Json.NETSerialize ExtensionData
 

This sample serializes an object with extension data into JSON.

Sample
Usage
 1string json = @"{
 2  'HourlyRate': 150,
 3  'Hours': 40,
 4  'TaxRate': 0.125
 5}";
 6
 7CustomerInvoice invoice = JsonConvert.DeserializeObject<CustomerInvoice>(json);
 8
 9// increase tax to 15%
10invoice.TaxRate = 0.15m;
11
12string result = JsonConvert.SerializeObject(invoice);
13// {
14//   "TaxRate": 0.15,
15//   "HourlyRate": 150,
16//   "Hours": 40
17// }