image

Ever wish you could work with JSON in .NET as you normally do with regular old objects? Well, now you can:

string url = "https://github.com/api/v2/repos/show/kamranayub";
dynamic[] repos = JsonService.GetFrom(url).repositories;

return View(repos.OrderByDescending(r => r.watchers);

Enter .JSON, a single file that holds 2 classes you can use to manipulate JSON in a dynamic way, either from web services, strings, or objects.

dynamic json = Json.Parse("{'foo':'bar','baz':['a','b','c']}");

string foo = json.foo;
string[] = json.baz;

Inspired by Massive, I decided this would be a useful tool for the community, seeing as all the existing JSON libraries for .NET are not exactly what I'd want when dealing with JSON data.

I wanted several things from this:

  • Ease of use
  • LINQ
  • Dynamically typed
  • GET, POST, and authentication support
  • One file
  • Minimal dependencies (there's one for using Microsoft's built-in serialization/deserialization of JSON but it's GAC'd at least).

I am happy to say that as it stands, I've accomplished all of them. If you spot bugs, open an issue or patch it. I plan to refactor it a little to support a Fluent interface, but other than that, it pretty much just works.

Happy JSON'ing!