8.13JSON Serialization Configuration
Created on Aug 17, 2026~3 min read
The framework uses System.Text.Json by default to handle JSON serialization for HTTP requests, supporting the following configuration approaches:
- Global default configuration
Set unified JSON serialization behavior for all HttpClient instances through HttpRemoteOptions:
services.AddHttpRemote(builder => {}) .ConfigureOptions(options => // Or use the overload: .ConfigureOptions((options, serviceProvider) => { options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; });- Client-level configuration (higher priority)
When both global and client-level configurations exist, the framework gives priority to the client-level configuration:
// Configure the default clientservices.AddHttpClient(string.Empty) .ConfigureOptions(options => // Or use the overload: .ConfigureOptions((options, serviceProvider) => { options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; });// Configure a specific clientservices.AddHttpClient("furion") .ConfigureOptions(options => // Or use the overload: .ConfigureOptions((options, serviceProvider) => { options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; });Usage example:
var model = await httpRemoteService.SendAsAsync<YourModel>(HttpRequestBuilder.Get("https://furion.net/test-json") .SetHttpClientName("furion")); // If not set, the default is string.Empty- Manual handling (full control)
When special handling is required, you can directly operate on the raw response:
var jsonString = await httpRemoteService.GetAsStringAsync("https://furion.net/test-json");var model = JsonSerializer.Deserialize<YourModel>(jsonString, new JsonSerializerOptions());If you want to replace the framework's default System.Text.Json serialization provider — for example, using Newtonsoft.Json to provide JSON serialization configuration options — you can satisfy this customization requirement by implementing the IHttpContentProcessor interface.