This project has moved and is read-only. For the latest updates, please go here.

var Anonymous Types

Nov 23, 2007 at 2:00 AM
Edited Nov 24, 2007 at 8:14 AM
Is it possible to serialize a var object to JSON either today or planned?

For example:
var p1 = new {Name = "Fallon", Price = 44};

There is no implicit type, so there is nothing to cast it to, however, the object will behave like a normal object, i.e.,

string name = p1.Name;

Any response will be welcome, thank you.

Further Information:
I have discovered that the var type can be cast as an Object type, and then the fields may be discovered by reflection. Therefore the above should be easily done.

On another note:
If this is implemented, then you can in effect produce a JSON to C# object that comes back as a var type. The var type will support intellisense in the IDE.