I have a complex data structure similar to the one below that I need to serialize into JSON for my client-side JavaScript:
public class MyObject
{
[title("title1")]
public int? MyInt{get;set;}
[title("title2")]
public string MyStr{get;set;}
// ETC
}
The current JSON serialization output is as follows:
{MyInt: '7', MyStr: 'Str'}
Now, I want the JSON output to be formatted like this instead:
{
MyInt: {value:'7', title:'title1', <Extra info>},
MyStr: {value:'Str', title:'title2', <Extra info>}
}
I'm looking for an efficient solution since this will be a common requirement in my system. Any suggestions on how to achieve this?