This project has moved. For the latest updates, please go here.

"Fake" object

Jan 23, 2008 at 10:58 AM
It would be really useful with a "fake" object you could incrementally add properties to. Something like:

JsonObject o = new JsonObject();
o"foo" = 1;
if (x > 10)
o"bar" = "baz";

JsonObject would then be serialized as an ordinary .NET object where o"foo" is considered as So the result would be like { "foo": 1 }. Makes sense?

It's useful for the cases where the other end is expecting a certain object which you don't have in this end and would rather avoid having to model, e.g. if the data comes directly from a non-OO data source.
Feb 8, 2008 at 11:12 PM
Any old IDictionary<string, object> will do what you're looking for. Its key/values will get turned into { "foo": 1, "bar":"baz", etc... }