I have an input request body for my ASP.NET Core MVC application which I am binding to a request model in C#.
public class Request
{
public int Index {get;set;}
public string DocType {get;set;}
public string DocId {get;set;}
}
This is my request JSON
{
"request" : [
{
"DocType" : "MSWORD",
"DocId" : "553ed6c232da426681b7c45c65131d33"
},
{
"DocType" : "MSEXCEL",
"DocId" : "256ed6c232da426681b7c45c651317895"
}]
}
I want to map this request to my C# model such that the Index
property is incremented automatically.
In other words, when I Deserialize my C# request to a JSON string it should look like this.
{
"request" : [
{
"Index" : 0,
"DocType" : "MSWORD",
"DocId" : "553ed6c232da426681b7c45c65131d33"
},
{
"Index" : 1,
"DocType" : "MSEXCEL",
"DocId" : "256ed6c232da426681b7c45c651317895"
}]
}