I have a C# class like this
public class Person
{
string firstname {get; set;}
string lastname {get; set;}
string onRenderFunction {get; set;}
}
Then I setup the class like this:
var superman = new Person
{
firstname = "Clark",
lastname = "Kent",
onRenderFunction = "renderPersonComplete"
}
What I want is the "onRenderFunction" to be serialized to a method - not a string. Like this;
{
"firstname": "Clark",
"lastname": "Kent",
"onRenderFunction": renderPersonComplete
}
So when the serialized object is returned via an Ajax call and given to a plugin which has the ability to call a function "onRenderFunction", the plugin would see the function is set and call a function setup like this:
var renderPersonComplete = function() {
alert('do something on render complete');
};
How would I setup JSON.NET to serialize the Person class to do this?