LINQ to JSON

Written by on February 12th, 2008 in Ajax News.

James Newton-King has posted a new bit of code called LINQ to JSON which is a .NET LINQ style API over JSON.

For example, here is how you could get out categories and how often they are used:

JAVASCRIPT:

var categories =
  from c in rss.PropertyValue<jobject>(”channel”)
              .PropertyValue<jarray>(”item”)
              .Children<jobject>()
              .PropertyValues<jarray>(”category”)
              .Children<string>()
  group c by c into g
  orderby g.Count() descending
  select new { Category = g.Key, Count = g.Count() };
 

There is also a project, JSLINQ which is an implementation of LINQ to Objects implemented in JavaScript. It is built using a set of extension methods built on top of the JavaScript Array object. If you are using an Array, you can use JSLINQ.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/233703944/linq-to-json

Comments are closed.



Site Navigation