I have a C# class
public class occ
{
public datetime from { get; set; }
public datetime to { get; set; }
public string Ktype { get; set; }
public flag bool { get; set; }
}
that I fill from an EF6.0 function coming from a stored procedure
I was asked to create for each record of that class a Json of this format
{
"Ktype": [
{
"from"
"to"
"flag"
}
]
}
I have a little experience with Json. Some folks here have helped me to catch up.
Until now I knew that the "outer" attribute (I do not know how to call it...sorry) came from the class name.
In this example the Ktype is a part of the class.
How can I Json-serialize this class and have Ktype as an outer Json attrib?
I want something like this:
{
"TRC": [{"from":"2016-02-09","to":"2016-02-16","flag":true}]
}
{
"TRX": [{"from":"2016-02-12","to":"2016-02-18","flag":false}]
}
ktypebecome an array (Its just a string in the class)? How do you map between the class and the required json?