I want to send a JSON model to the front as follows:
Here it is:
{
"2020-01-22":1,
"2020-01-23":2,
"2020-01-24":3,
..
}
I have data that I pulled through the database. Here is my class for the list of objects:
public class MyClass
{
public string DateTime { get; set; }
public int? Data { get; set; }
}
I fill my list using this model and send it to the front side as JSON.
{
"dateTime": "2020-01-22",
"data": 1
},
{
"dateTime": "2020-01-23",
"data": 2
},
..
How can I create the JSON model I originally defined? The programming language I use is C# and .NET Core.