Tuesday, April 8, 2008

LINQ to JSON

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("channel")
.PropertyValue("item")
.Children()
.PropertyValues("category")
.Children()
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.

0 comments: