For a project i've created several struct in C#. The probject itself is a ASP.Net MVC 2 project.
snip:
struct TDummy
{
private char _value;
public TDummy(char value)
{
this._value = value; // Restrictions
}
}
I created this because I needed to restrict a char-variable to a specific number of values. (I could have created an Enum, but these values are also used in the database, and then i would still need to convert them)
Now i need to create a JsonResult, like
return Json(new { Value = new TDummy('X') });
But when I do this, I get a result of:
{"Value":{}}
I expected to get a result of
{"Value":"X"}
I've tried several things, like TypeConverter (CanConvertTo(string)), Custom Type Serializer (JavaScriptSerializer.RegisterConverters()), but either they don't work or they must return a 'Complex' json-object.
{"Value":{"Name":"Value"}}
Any thoughts on this?
I want to serialize a value-type as a value...
If anyone is interested, i've create a small demo (console app) to illustrate this: