ASP.NET Core Web API Interview Question #30

How is JSON request data deserialized in ASP.NET Core Web API?

DTOs, Model Binding, Validation & API Responses Junior Beginner

Quick Interview Answer

ASP.NET Core uses configured input formatters to deserialize request content into .NET objects. JSON is the standard format for modern APIs and is handled by System.Text.Json by default.

Detailed Explanation

ASP.NET Core uses configured input formatters to deserialize request content into .NET objects. JSON is the standard format for modern APIs and is handled by System.Text.Json by default.

Property naming, enum handling, reference behavior, and other serialization settings can be configured globally when the API contract requires it.

Code Example

builder.Services.AddControllers()
    .AddJsonOptions(options =>
    {
        options.JsonSerializerOptions.PropertyNamingPolicy =
            JsonNamingPolicy.CamelCase;
    });