From 139fd753e5d7a7a4a160303dca6cd52c04500ed1 Mon Sep 17 00:00:00 2001 From: Megha Anand <88059806+anandmeg@users.noreply.github.com> Date: Thu, 2 Oct 2025 12:56:00 -0700 Subject: [PATCH 1/4] Revise AI highlight example --- .../migrate-from-newtonsoft.md | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md index cd458b56d5d0d..3968919c0bbb0 100644 --- a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md +++ b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md @@ -2,7 +2,7 @@ title: "Migrate from Newtonsoft.Json to System.Text.Json - .NET" description: "Learn about the differences between Newtonsoft.Json and System.Text.Json and how to migrate to System.Text.Json." no-loc: [System.Text.Json, Newtonsoft.Json] -ms.date: 02/11/2025 +ms.date: 10/02/2025 helpviewer_keywords: - "JSON serialization" - "serializing objects" @@ -639,26 +639,22 @@ System.Text.Json sets limits that can't be changed for some values, such as the Newtonsoft parses `NaN`, `Infinity`, and `-Infinity` JSON string tokens. With System.Text.Json, use . For information about how to use this setting, see [Allow or write numbers in quotes](invalid-json.md#allow-or-write-numbers-in-quotes). -## Use AI to migrate +## Use AI for solution-wide migration -You can use AI tools, such as GitHub Copilot, to migrate your code from `Newtonsoft.Json` to `System.Text.Json` within your IDE. You can customize the prompt per your requirements. +You can use AI tools, such as GitHub Copilot, to help with migrating your solution from `Newtonsoft.Json` to `System.Text.Json` directly within your IDE, using a tailored prompt that reflects your project’s specific serialization patterns and requirements. **Example prompt for Copilot Chat** ```copilot-prompt -convert the following code to use System.Text.Json -Product product = new Product(); - -product.Name = "Apple"; -product.ExpiryDate = new DateTime(2024, 08, 08); -product.Price = 3.99M; -product.Sizes = new string[] { "Small", "Medium", "Large" }; - -string output = JsonConvert.SerializeObject(product); -Console.WriteLine(output); +Convert all serialization code in this #solution from Newtonsoft.Json to System.Text.Json, using the recommended approach for my current .NET version. +- Update attributes and properties, including rules for skipping or renaming during serialization +- Ensure polymorphic serialization continues to work correctly +- Respect existing custom converters and project-level settings (for example, from the Utilities folder or appsettings.json) +- Update related unit tests and highlight any potential breaking changes +- Generate a migration summary ``` -GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). +For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). ## Additional resources From 6e58dc52afea7941c3815b0400e5d5002869fe76 Mon Sep 17 00:00:00 2001 From: Megha Anand <88059806+anandmeg@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:28:48 -0700 Subject: [PATCH 2/4] Fix build warning --- .../serialization/system-text-json/migrate-from-newtonsoft.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md index 3968919c0bbb0..26c820faf776f 100644 --- a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md +++ b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md @@ -24,7 +24,7 @@ The `System.Text.Json` namespace provides functionality for serializing to and d * .NET Core 2.0, 2.1, and 2.2 > [!TIP] -> You can use AI assistance to [migrate from `Newtonsoft.Json`](#use-ai-to-migrate). +> You can use AI assistance to [migrate from `Newtonsoft.Json`](#use-ai-for-solution-wide-migration). `System.Text.Json` focuses primarily on performance, security, and standards compliance. It has some key differences in default behavior and doesn't aim to have feature parity with `Newtonsoft.Json`. For some scenarios, `System.Text.Json` currently has no built-in functionality, but there are recommended workarounds. For other scenarios, workarounds are impractical. @@ -654,7 +654,7 @@ Convert all serialization code in this #solution from Newtonsoft.Json to System. - Generate a migration summary ``` -For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). +Review Copilot’s suggestions before applying. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). ## Additional resources From b57b42b21fe565d1545df511d251b3927ab276fc Mon Sep 17 00:00:00 2001 From: Megha Anand <88059806+anandmeg@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:38:38 -0700 Subject: [PATCH 3/4] Updates per feedback --- .../system-text-json/migrate-from-newtonsoft.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md index 26c820faf776f..5997c62459a71 100644 --- a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md +++ b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md @@ -2,7 +2,7 @@ title: "Migrate from Newtonsoft.Json to System.Text.Json - .NET" description: "Learn about the differences between Newtonsoft.Json and System.Text.Json and how to migrate to System.Text.Json." no-loc: [System.Text.Json, Newtonsoft.Json] -ms.date: 10/02/2025 +ms.date: 10/03/2025 helpviewer_keywords: - "JSON serialization" - "serializing objects" @@ -641,7 +641,8 @@ Newtonsoft parses `NaN`, `Infinity`, and `-Infinity` JSON string tokens. With Sy ## Use AI for solution-wide migration -You can use AI tools, such as GitHub Copilot, to help with migrating your solution from `Newtonsoft.Json` to `System.Text.Json` directly within your IDE, using a tailored prompt that reflects your project’s specific serialization patterns and requirements. +You can use AI tools, such as GitHub Copilot, to help with migrating your solution code from `Newtonsoft.Json` to `System.Text.Json` directly within your IDE. You can use a tailored prompt that reflects your project’s specific serialization patterns and requirements. +Here's an example prompt you can use in Visual Studio Copilot Chat to migrate a solution. **Example prompt for Copilot Chat** @@ -654,7 +655,7 @@ Convert all serialization code in this #solution from Newtonsoft.Json to System. - Generate a migration summary ``` -Review Copilot’s suggestions before applying. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). +It's recommended that you review Copilot's suggestions before applying them. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). ## Additional resources From 53563774654e13f8cf0266eb60ac588424cf54e2 Mon Sep 17 00:00:00 2001 From: Megha Anand <88059806+anandmeg@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:43:06 -0700 Subject: [PATCH 4/4] Updates per Mike's feedback Removed redundant text about using AI tools for migration and streamlined the example prompt section. --- .../system-text-json/migrate-from-newtonsoft.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md index 5997c62459a71..0dc0a15f12af1 100644 --- a/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md +++ b/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md @@ -641,10 +641,9 @@ Newtonsoft parses `NaN`, `Infinity`, and `-Infinity` JSON string tokens. With Sy ## Use AI for solution-wide migration -You can use AI tools, such as GitHub Copilot, to help with migrating your solution code from `Newtonsoft.Json` to `System.Text.Json` directly within your IDE. You can use a tailored prompt that reflects your project’s specific serialization patterns and requirements. -Here's an example prompt you can use in Visual Studio Copilot Chat to migrate a solution. +You can use AI tools, such as GitHub Copilot, to help with migrating your solution code from `Newtonsoft.Json` to `System.Text.Json`. -**Example prompt for Copilot Chat** +Here's an example prompt you can use in Visual Studio Copilot Chat to migrate a solution. ```copilot-prompt Convert all serialization code in this #solution from Newtonsoft.Json to System.Text.Json, using the recommended approach for my current .NET version. @@ -655,7 +654,7 @@ Convert all serialization code in this #solution from Newtonsoft.Json to System. - Generate a migration summary ``` -It's recommended that you review Copilot's suggestions before applying them. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). +Review Copilot's suggestions before applying. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). ## Additional resources