For the project, I created several structures in C #. The project itself is an ASP.Net MVC 2 project.
notch:
struct TDummy
{
private char _value;
public TDummy(char value)
{
this._value = value;
}
}
I created this because I needed to limit char -variable to a specific number of values. (I could create an Enum, but these values ββare also used in the database, and then I still need to convert them)
Now I need to create a JsonResult, for example
return Json(new { Value = new TDummy('X') });
But when I do this, I get the result:
{"Value":{}}
I expected to get the result.
{"Value":"X"}
I tried several things, such as TypeConverter (CanConvertTo (string)), Serial type of user type (JavaScriptSerializer.RegisterConverters ()), but either they do not work, or they should return a jso object Complex./p>
{"Value":{"Name":"Value"}}
Any thoughts on this?
I want to serialize value-type as value ...