I would like to write a JavaScript converter that outputs in JSON rather than an IDictionary<string,object>.
Why? Say for instance I have a class:
class MyClass
{
public int X;
public int Y;
public int Add()
{
return X + Y;
}
public int Subtract()
{
return X - Y;
}
public int Average
{
get
{
return (X + Y) / 2;
}
}
}
and I want to serialize this class to JSON like this:
<script type='text/javascript'>
var myc =
{
"X" : 21,
"Y" : 99,
"Add" : function() {
return X + Y;
},
"Subtract" : function() {
return X - Y;
} ...
Go to the complete details ...