Skip to content

Configurable JSON serialization support (Newtonsoft.Json vs System.Text.Json) #1341

@serber

Description

@serber

WireMock.Net forces me to use Newtonsoft.Json as the only serialization option. In modern .NET applications that have migrated to System.Text.Json, this creates dependency conflicts, performance overhead, and inconsistent serialization behavior between production code and test mocks. When my application uses System.Text.Json with specific naming policies and converters, WireMock's Newtonsoft.Json serialization can produce different results, leading to unreliable tests that don't accurately reflect production behavior.

I would like WireMock.Net to support configurable JSON serialization, allowing users to choose between Newtonsoft.Json (current default) and System.Text.Json. This could be implemented through:

// Configuration option
WireMockServer.Start(new WireMockServerSettings
{
    JsonSerializer = JsonSerializerType.SystemTextJson
});

// Or fluent API
var server = WireMockServer
    .Start()
    .UseSystemTextJson()
    .WithSettings(settings);

Additional context

  • System.Text.Json offers significantly better performance (up to 2x faster serialization)
  • Many .NET 5+ projects have migrated away from Newtonsoft.Json
  • Microsoft recommends System.Text.Json for new applications
  • This feature would help WireMock.Net stay current with .NET ecosystem trends
  • Backward compatibility can be maintained by keeping Newtonsoft.Json as the default option
  • Would be valuable for high-throughput testing scenarios where serialization performance matters

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions