Monday, March 3rd, 2008
Json.NET 2.0
James Newton-King has quickly released a new version of Json.NET that has a new easier syntax for querying and and creating JSON.
Creating JSON
JAVASCRIPT:
-
-
JObject o = JObject.FromObject(new
-
{
-
channel = new
-
{
-
title = "James Newton-King",
-
link = "http://james.newtonking.com",
-
description = "James Newton-King's blog.",
-
item =
-
from p in posts
-
orderby p.Title
-
select new
-
{
-
title = p.Title,
-
description = p.Description,
-
link = p.Link,
-
category = p.Categories
-
}
-
}
-
});
-
Querying JSON
JAVASCRIPT:
-
-
var categories =
-
from c in rss["channel"]["item"].Children()["category"].Values<string>()
-
group c by c into g
-
orderby g.Count() descending
-
select new { Category = g.Key, Count = g.Count() };
-





3.7 rating from 24 votes








This looks good. I use Json.NET when I’m not using ASP.NET AJAX and it’s very useful.
@Dion: I think the two code examples are in C# not JavaScript.
These cliche web 2.0 logos aren’t funny anymore, just irritating
Just a quick correction: the first code block appears to be C# code using LINQ to populate a JSON object (using new fangled C# features like anonymous types and variable instantiation)
thank you.
Thanks. Good article.
Interesting Article, thanks Armenian Genocide , great information and research.