I'm sending that kind of json to asp.net web api action.
{
"keys": {
"2a":["C",,,,,"0",,"0"]
}
}
This json is POST-ed exactly as it is in request body to my asp.net 4.5 web api 2 action.
[RoutePrefix("api/TImport")]
[Authorize]
public class TImportController : ApiController
{
[Route("")]
[HttpPost]
public async Task<TImportResult> Post(TImportParameters parameters)
{
// parameters.Keys["2a"] got deserialized as array[3] {"C","0","0" } :((
return await new TImport().RunAsync(parameters);
}
What happens is that the 2a is deserialized into array of 3 elements instead of 8 elements with null or empty elements 2 to 6 and 7.
What can I do to to desserialize skipped array elements as defaults (nulls or empty strings)?
nullwithnullas default.2acannot be a property name of a C# object.