This project has moved and is read-only. For the latest updates, please go here.
Project Description
JSON Dynamic Object (JDO) is a small and lightweight library that provides a simple paradigm of working with JSON objects in .Net.


JSON Dynamic Object

At it's heart, JDO is just a wrapper around JavaScriptSerializer . It utilizes C# 4.0's dynamic keyword, as well as the new DynamicObject class to provide a simple to use wrapper class around JSON objects. Not only does it make deserializing JSON into native types simple, but it makes generating JSON much more like writing javascript than C# code.

It's easiest to understand JDO with a few basic examples:

Reading JSON
using JDO;

dynamic json = JSON.Deserialize("\foo"\":\"bar\",\"baz\":3");
Console.WriteLine("foo is: {0}, baz is: {1}", json.foo, json.baz);

Creating JSON with accessor syntax
using JDO;
using JDO.Dynamic;

// Using accessor notation
dynamic json = new DynObject();
json.foo = "bar";
json.baz = 3;

Console.WriteLine("json is: \"{0}\"", JSON.Serialize(json));

Creating JSON with Collection Initializer syntax
using JDO;
using JDO.Dynamic;

// Using Collection Initializer notation
dynamic json = new DynObject {{"foo", "bar"}, {"baz", 3}};

Console.WriteLine("json is: \"{0}\"", JSON.Serialize(json));

Last edited Feb 23, 2012 at 6:39 PM by Morgul, version 3