Click or drag to resize
Json.NET

Using LINQ to JSON Annotations

 

This sample uses annotations with LINQ to JSON objects.

Sample
Usage
JObject o = JObject.Parse(@"{
  'name': 'Bill G',
  'age': 58,
  'country': 'United States',
  'employer': 'Microsoft'
}");

o.AddAnnotation(new HashSet<string>());
o.PropertyChanged += (sender, args) => o.Annotation<HashSet<string>>().Add(args.PropertyName);

o["age"] = 59;
o["employer"] = "Bill & Melinda Gates Foundation";

HashSet<string> changedProperties = o.Annotation<HashSet<string>>();
// age
// employer