Bespoke Software Solutions in C#.Net, ASP.Net MVC, JQuery, MEF and more
Posts tagged jlinq
jLinq – LINQ for JSON
Oct 19th

Sometimes I stumble accross something and immediately think “where has this been all my life?”. Finding jLinq is one of those moments.
I love Language Integrated Query (LINQ) and have used it for the last couple of years. With LINQ2NHibernate, LINQ2Lucene, LINQ2Amazon and even LINQ2Twitter emerging, it is very clear that LINQ is here to stay.
I love Language Integrated Query (LINQ) and have used it for the last couple of years. With LINQ2NHibernate, LINQ2Lucene, LINQ2Amazon and even LINQ2Twitter emerging, it is very clear that LINQ is here to stay.
Enter jLinq from Hugoware…
$.getJSON("/Person/All", function(data) {
var results = jLinq.from(data.users)
.startsWith("first", "a")
.orEndsWith("y")
.orderBy("admin", "age")
.select();
});
You can view the basics of jLinq from this screencast.
We used jLinq to solve a very complex join operation on our JSON object and found it to be a very simple task…
var results = jLinq.from(data.users)
.join(data.locations, "location", "locationId", "id")
.equals("location.state", "texas")
.orderBy("location.city")
.select(function(r) {
return {
fullname:r.first + " " + r.last,
city:r.location.city,
state:r.location.state
};
});
jLinq is also very extensible and creating your own extension methods couldnt be easier…
jLinq.extend({
name:"startsWithLetterP",
type:"query",
count:0,
method:function(q) {
return q.helper.match(q.value, /^p/);
}});
//use the new method
var results = jLinq.from(data.users)
.startsWithLetterP("first")
.select();
So why wait another minute, head off to experiment here right now!