Click or drag to resize
Json.NETLINQ to JSON
 

LINQ to JSON is an API for working with JSON objects. It has been designed with LINQ in mind to enable quick querying and creation of JSON objects. LINQ to JSON sits under the Newtonsoft.Json.Linq namespace.

Using LINQ for JSON
 1JObject o = JObject.Parse(@"{
 2  'CPU': 'Intel',
 3  'Drives': [
 4    'DVD read/writer',
 5    '500 gigabyte hard drive'
 6  ]
 7}");
 8
 9string cpu = (string)o["CPU"];
10// Intel
11
12string firstDrive = (string)o["Drives"][0];
13// DVD read/writer
14
15IList<string> allDrives = o["Drives"].Select(t => (string)t).ToList();
16// DVD read/writer
17// 500 gigabyte hard drive
Topics
See Also