Skip to main content
Source: AL0027AvoidNewtonsoftJsonAnalyzer.cs

Description

The legacy JSON library (Newtonsoft.Json) should be replaced with System.Text.Json for better performance and native .NET support. This rule only triggers when System.Text.Json is available in the project, making migration possible.

Bad Code

Good Code

Properties

  • Category: Usage
  • Severity: Warning
  • Enabled by default: True
  • Code fix available: False

Configuration

Notes

System.Text.Json is the recommended JSON library for .NET applications. It offers:
  • Better performance (faster serialization/deserialization)
  • Lower memory allocations
  • Native integration with ASP.NET Core
  • Source generator support for AOT compilation