Skip to content

Commit 4a46a34

Browse files
authored
Revise AI highlight example (#48880)
* Revise AI highlight example * Fix build warning * Updates per feedback * Updates per Mike's feedback Removed redundant text about using AI tools for migration and streamlined the example prompt section.
1 parent 5ce6253 commit 4a46a34

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Migrate from Newtonsoft.Json to System.Text.Json - .NET"
33
description: "Learn about the differences between Newtonsoft.Json and System.Text.Json and how to migrate to System.Text.Json."
44
no-loc: [System.Text.Json, Newtonsoft.Json]
5-
ms.date: 02/11/2025
5+
ms.date: 10/03/2025
66
helpviewer_keywords:
77
- "JSON serialization"
88
- "serializing objects"
@@ -24,7 +24,7 @@ The `System.Text.Json` namespace provides functionality for serializing to and d
2424
* .NET Core 2.0, 2.1, and 2.2
2525

2626
> [!TIP]
27-
> You can use AI assistance to [migrate from `Newtonsoft.Json`](#use-ai-to-migrate).
27+
> You can use AI assistance to [migrate from `Newtonsoft.Json`](#use-ai-for-solution-wide-migration).
2828
2929
`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.
3030

@@ -639,26 +639,22 @@ System.Text.Json sets limits that can't be changed for some values, such as the
639639

640640
Newtonsoft parses `NaN`, `Infinity`, and `-Infinity` JSON string tokens. With System.Text.Json, use <xref:System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals?displayProperty=nameWithType>. For information about how to use this setting, see [Allow or write numbers in quotes](invalid-json.md#allow-or-write-numbers-in-quotes).
641641

642-
## Use AI to migrate
642+
## Use AI for solution-wide migration
643643

644-
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.
644+
You can use AI tools, such as GitHub Copilot, to help with migrating your solution code from `Newtonsoft.Json` to `System.Text.Json`.
645645

646-
**Example prompt for Copilot Chat**
646+
Here's an example prompt you can use in Visual Studio Copilot Chat to migrate a solution.
647647

648648
```copilot-prompt
649-
convert the following code to use System.Text.Json
650-
Product product = new Product();
651-
652-
product.Name = "Apple";
653-
product.ExpiryDate = new DateTime(2024, 08, 08);
654-
product.Price = 3.99M;
655-
product.Sizes = new string[] { "Small", "Medium", "Large" };
656-
657-
string output = JsonConvert.SerializeObject(product);
658-
Console.WriteLine(output);
649+
Convert all serialization code in this #solution from Newtonsoft.Json to System.Text.Json, using the recommended approach for my current .NET version.
650+
- Update attributes and properties, including rules for skipping or renaming during serialization
651+
- Ensure polymorphic serialization continues to work correctly
652+
- Respect existing custom converters and project-level settings (for example, from the Utilities folder or appsettings.json)
653+
- Update related unit tests and highlight any potential breaking changes
654+
- Generate a migration summary
659655
```
660656

661-
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).
657+
Review Copilot's suggestions before applying. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
662658

663659
## Additional resources
664660

0 commit comments

Comments
 (0)