Tuesday, February 12th, 2008

LINQ to JSON

Category: .NET, JSON

<p>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
< view plain text >
  1. var categories =
  2.   from c in rss.PropertyValue<jobject>("channel")
  3.               .PropertyValue<jarray>("item")
  4.               .Children<jobject>()
  5.               .PropertyValues<jarray>("category")
  6.               .Children<string>()
  7.   group c by c into g
  8.   orderby g.Count() descending
  9.   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.

Related Content:

Posted by Dion Almaer at 7:00 am
5 Comments

+++--
3.9 rating from 26 votes

5 Comments »

Comments feed TrackBack URI

Just to be complete: there’s also PHPLinq on http://codeplex.com/PHPLinq .

Comment by maartenba — February 12, 2008

One word, EXCELLENT!

Comment by Liming — February 12, 2008

Jaql (http://www.jaql.org/) looks like another one.

Comment by michele — February 12, 2008

how about dynamic linq, I think that’s more useful than normal linq

Comment by phpcs — February 12, 2008

Very cool…. nice to see LINQ crossing the Microsoft chasm.

Comment by jonbruce — February 12, 2008

Leave a comment

You must be logged in to post a comment.