You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/standard/serialization/system-text-json/how-to.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "How to serialize JSON in C#"
3
3
description: "Learn how to use the System.Text.Json namespace to serialize to JSON in .NET. Includes sample code."
4
-
ms.date: 02/11/2025
4
+
ms.date: 11/20/2025
5
5
no-loc: [System.Text.Json, Newtonsoft.Json]
6
6
dev_langs:
7
7
- "csharp"
@@ -110,14 +110,14 @@ Starting in .NET 9, you can also customize the indent character and size using <
110
110
111
111
## Use AI to serialize to JSON
112
112
113
-
You can use AI tools, such as GitHub Copilot, to generate code that uses `System.Text.Json` to serialize to JSON. You can customize the prompt to use object fields that suit your requirements.
113
+
You can use AI tools, such as GitHub Copilot, to generate code that uses `System.Text.Json` to serialize to JSON. You can customize the prompt to fit your object fields and serialization needs.
114
114
115
-
The following text shows an example prompt for Copilot Chat:
115
+
Here's an example prompt you can use to generate serialization code:
116
116
117
117
```copilot-prompt
118
-
Generate code to use System.Text.Json to serialize an object to a JSON string.
119
-
The object contains the following fields: FirstName (string), Lastname (string), Age (int).
120
-
Provide example output.
118
+
I have a variable named weatherForecast of type WeatherForecast.
119
+
Serialize the variable using System.Text.Json and write the result directly to a file named "output.json" with the JSON indented for pretty formatting.
120
+
Ensure the code includes all necessary using directives and compiles without errors.
121
121
```
122
122
123
123
Review Copilot's suggestions before applying them.
@@ -127,4 +127,4 @@ For more information about GitHub Copilot, see GitHub's [FAQs](https://github.co
127
127
## See also
128
128
129
129
-[GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states)
130
-
-[GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview)
130
+
-[GitHub Copilot in Visual Studio Code](https://code.visualstudio.com/docs/copilot/overview)
0 commit comments