Map JSON object to class c# property Use case : I am creating API in Azure Function and passing parameter-ReservationDraftRequestDto class like below code
[FunctionName("Function1")] public static async Task Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] ReservationDraftRequestDto reservationDraftRequestDto, ILogger log) { }
DTO class:
API URI: http://localhost:7071/api/Function1 JSON-for calling API is: { "SoftHoldIDs": 444, "AppliedUsages": [ { "SoftHoldID": 444, "UsageYearID": 4343, "DaysApplied": 0, "PointsApplied": 1 } ], "Guests": [ 1, 2 ] }
public class ReservationDraftRequestDto
{
public int SoftHoldIDs { get; set; }
public int[] Guests { get; set; }
public AppliedUsage[] AppliedUsages { get; set; }
}
public class AppliedUsage
{
public int SoftHoldID { get; set; }
public int UsageYearID { get; set; }
public int DaysApplied { get; set; }
public int PointsApplied { get; set; }
}
Issue is: When i called API with above payload then API class parameter-ReservationDraftRequestDto not mapped AppliedUsages array values.
Please let me know what i need to do map API JSON payload to ReservationDraftRequestDto