Monday, March 3rd, 2008
Json.NET 2.0
<p>
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
-
-
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
-
-
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() };
-
Related Content:











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.
Thats great thanks
It’s Good,Really it is very good.
we web designing company also doing works in .net.
please feel free to contact us at http://www.technowizpvtltd.com