system-text-json-net11
Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed `JsonSerializerOptions.GetTypeInfo<T>()` and `JsonSerializerOptions.TryGetTypeInfo<T>(out JsonTypeInfo<T>? info)` metadata accessors.
Install / Use
npx skills add dotnet/skills --skill system-text-json-net11Installs into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Content & MediaSupported Platforms
Our assessment of system-text-json-net11
system-text-json-net11 scores 87/100 on our quality scale, 262nd of 504 Content & Media skills we index.
Its SKILL.md is 15 KB long, well organised into 14 sections with 9 code examples: a thorough specification that gives an agent plenty to work with.
With 5,471 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 2 days ago, so system-text-json-net11 is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
system-text-json-net11 compared with similar skills
All 4 of these similar skills score higher than system-text-json-net11; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| system-text-json-net11 (this skill)by dotnet | 87 | 5.5k | 2d ago | SKILL.md |
| Agent-Reachby Panniantong | 100 | 85.6k | 11d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 73.9k | today | CLAUDE.md |
| Scraplingby D4Vinci | 100 | 83.9k | today | MCP Server |
| LocalAIby mudler | 100 | 49.3k | today | MCP Server |
Frequently asked questions
- How do I install system-text-json-net11?
- Run
npx skills add dotnet/skills --skill system-text-json-net11. The install tabs above show the steps for each supported agent. - Which AI agents does system-text-json-net11 work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is system-text-json-net11 safe to use?
- It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is system-text-json-net11 still maintained?
- The repository was last updated 2 days ago, so system-text-json-net11 is actively maintained.
Skill content
View source on GitHubname: system-text-json-net11
description: >
Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in
JsonNamingPolicy.PascalCase naming policy, and the strongly-typed
JsonSerializerOptions.GetTypeInfo<T>() and
JsonSerializerOptions.TryGetTypeInfo<T>(out JsonTypeInfo<T>? info)
metadata accessors.
USE ONLY when the user is targeting net11.0 or later and needs
PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed
JsonTypeInfo<T> instead of the non-generic JsonTypeInfo, or a no-throw way to probe
whether a type's serialization metadata is resolved.
DO NOT USE when the target is earlier than net11.0, the requested behavior uses an
established pre-net11 naming policy, or the user explicitly selected another JSON library.
license: MIT
System.Text.Json — .NET 11
Three APIs were added to System.Text.Json in .NET 11. This skill tells you exactly
when to reach for each one, what to write, what not to write, and how to prove the
result runs. Do not describe these APIs to the user — apply them, then run the code and
show the output.
| API | Replaces the pre-.NET-11 workaround of... |
| --- | --- |
| JsonNamingPolicy.PascalCase (static property) | writing a custom JsonNamingPolicy subclass or hand-annotating every member with [JsonPropertyName] |
| JsonSerializerOptions.GetTypeInfo<T>() | calling non-generic GetTypeInfo(typeof(T)) and casting to JsonTypeInfo<T> |
| JsonSerializerOptions.TryGetTypeInfo<T>(out JsonTypeInfo<T>? info) | wrapping GetTypeInfo in try/catch to probe availability |
Step 0 — Make the requested net11.0 validation possible
These APIs only exist in the .NET 11 base class library. Before writing code:
- Run
dotnet --list-sdksand confirm an SDK that can targetnet11.0is present — an11.xSDK, or a later SDK with thenet11.0targeting pack. - If the user explicitly asks you to run the sample and no suitable SDK is installed,
use the official
dotnet-installscript to install the current .NET 11 SDK into a temporary or project-local directory. Prefer the GA channel build. Use a preview only when GA is not yet available or the user explicitly requested a preview. Do not require administrator access, change the machine-widePATH, or replace an installed SDK. - Run the sample with that local
dotnetexecutable. If download or execution is blocked, still provide the completenet11.0program and report that it was not run. Never substitutenet10.0, a custom naming policy, or a different API and present that as validation of the .NET 11 feature.
Use the channel, not a guessed version. Try the GA channel first:
$installScript = Join-Path $env:TEMP "dotnet-install-$([guid]::NewGuid()).ps1"
try {
Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -OutFile $installScript
& $installScript -Channel 11.0 -InstallDir .\.dotnet
& .\.dotnet\dotnet.exe run --project <PATH_TO_NET11_PROJECT>
}
finally {
Remove-Item -LiteralPath $installScript -Force -ErrorAction SilentlyContinue
}
install_script="$(mktemp "${TMPDIR:-/tmp}/dotnet-install.XXXXXX")"
trap 'rm -f "$install_script"' EXIT
curl -fsSL https://dot.net/v1/dotnet-install.sh -o "$install_script"
bash "$install_script" --channel 11.0 --install-dir ./.dotnet
./.dotnet/dotnet run --project <PATH_TO_NET11_PROJECT>
Before .NET 11 GA, retry the install with -Quality preview (PowerShell) or
--quality preview (shell).
Decision table — symptom → do this → never do this
Match the user's request to a row, apply the Do this cell verbatim, and confirm the Verify column before you are done.
| User asks for… | Do this (on net11.0) | Never do this | Verify |
| --- | --- | --- | --- |
| PascalCase JSON property names | options.PropertyNamingPolicy = JsonNamingPolicy.PascalCase; | define class …: JsonNamingPolicy; add per-member [JsonPropertyName]; string-case the names yourself | output JSON keys are PascalCase — e.g. "Name", "Age" |
| PascalCase dictionary keys | options.DictionaryKeyPolicy = JsonNamingPolicy.PascalCase; | set only PropertyNamingPolicy; pre-transform the dictionary; define a custom policy | dictionary keys such as pendingOrders become "PendingOrders" |
| Strongly-typed metadata JsonTypeInfo<T> | set TypeInfoResolver = new DefaultJsonTypeInfoResolver(), then JsonTypeInfo<T> ti = options.GetTypeInfo<T>(); | (JsonTypeInfo<T>)options.GetTypeInfo(typeof(T)) | variable is typed JsonTypeInfo<T>, no cast |
| Probe whether metadata is resolved | if (options.TryGetTypeInfo<T>(out var ti)) { … } else { … } | try { options.GetTypeInfo<T>(); } catch (…) { … } | no try/catch; both branches handled |
Rule 1 — PascalCase property names
When the user wants JSON output whose property names are PascalCase (Name, Age)
and asks for the built-in / framework-provided way:
- Create or reuse a
JsonSerializerOptionsand setPropertyNamingPolicy = JsonNamingPolicy.PascalCase. - Serialize with those options.
Do not write a JsonNamingPolicy subclass, do not add [JsonPropertyName("…")]
attributes to force casing, and do not upper-case the first letter of each name by
hand. JsonNamingPolicy.PascalCase is the single correct answer on .NET 11.
// Console project (reflection enabled by default). To run this as a file-based app
// (dotnet run app.cs), also set TypeInfoResolver = new DefaultJsonTypeInfoResolver()
// — see "Producing runnable output" below.
using System.Text.Json;
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.PascalCase
};
string json = JsonSerializer.Serialize(new { name = "Jane", age = 30 }, options);
Console.WriteLine(json);
// {"Name":"Jane","Age":30}
Dictionary keys are a separate setting
PropertyNamingPolicy does not transform Dictionary<string, TValue> keys. For that
request, set DictionaryKeyPolicy:
var options = new JsonSerializerOptions
{
DictionaryKeyPolicy = JsonNamingPolicy.PascalCase
};
var values = new Dictionary<string, int>
{
["pendingOrders"] = 2,
["activeUsers"] = 5
};
Console.WriteLine(JsonSerializer.Serialize(values, options));
// {"PendingOrders":2,"ActiveUsers":5}
Rule 2 — Strongly-typed JsonTypeInfo<T>
When the user wants type metadata back as JsonTypeInfo<T> (not the non-generic
JsonTypeInfo that needs a cast):
- Call
options.GetTypeInfo<T>()— it returnsJsonTypeInfo<T>directly. - Assign it to a
JsonTypeInfo<T>variable and use it (e.g. pass it toJsonSerializer.Serialize/Deserialize).
Do not call the non-generic GetTypeInfo(Type) overload and cast the result.
Requires a resolver.
GetTypeInfo<T>()throwsNotSupportedException(NoMetadataForType) unless the options have aTypeInfoResolver— setTypeInfoResolver = new DefaultJsonTypeInfoResolver()for reflection-based apps, or use a source-generatedJsonSerializerContextfor trimmed/AOT apps.
// File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
// set <TargetFramework>net11.0</TargetFramework> in the project file instead.
#:property TargetFramework=net11.0
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
var options = new JsonSerializerOptions
{
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};
JsonTypeInfo<Person> typeInfo = options.GetTypeInfo<Person>();
Console.WriteLine(typeInfo.Type.Name); // Person
record Person(string Name, int Age);
Rule 3 — Probe metadata without throwing
When the user wants to check whether metadata for T is available and branch on it —
without an exception being thrown when it is not:
- Call
options.TryGetTypeInfo<T>(out var info). - Handle the
truebranch (metadata resolved, useinfo) and thefalsebranch (not resolved) explicitly.
Do not wrap GetTypeInfo<T>() in try/catch to detect the missing case — that is
exactly the anti-pattern this API removes. TryGetTypeInfo<T> returns false (instead of
throwing) when no resolver can produce metadata for T, which is precisely the case you
want to branch on.
// File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
// set <TargetFramework>net11.0</TargetFramework> in the project file instead.
#:property TargetFramework=net11.0
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
// Configured with a resolver → metadata is available.
var configured = new JsonSerializerOptions
{
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};
if (configured.TryGetTypeInfo<Person>(out JsonTypeInfo<Person>? info) && info is not null)
{
Console.WriteLine($"Resolved: {info.Type.Name}"); // Resolved: Person
}
else
{
Console.WriteLine("Type info not available");
}
// No resolver → TryGetTypeInfo returns false instead of throwing.
var empty = new JsonSerializerOptions();
Console.WriteLine(empty.TryGetTypeInfo<Person>(out _)); // False
record Person(string Name, int Age);
Producing runnable output on net11.0
The task is not done until the program runs on net11.0 and prints its JSON. Prefer a
console project — reflection-based serialization works there out of the box. A
file-based app also works but has one important caveat (below).
When the installed SDK cannot target net11.0 and execution was requested, install an
SDK locally with the official script and invoke it by full path. The install script is
non-administrative and does not persistently alter PATH.
Option A — console project (recommended)
Create a project whose .csproj contains <TargetFramework>net11.0</TargetFramework>,
put the code in Program.cs, then run dotnet run. Confirm the process exits with code 0
and prints the expected JSON.
using System.Text.Json;
var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.PascalCase };
Console.WriteLine(JsonSerializer.Serialize(new { name = "Jane", age = 30 }, options));
// {"Name":"Jane","Age":30}
Option B — file-based app (quickest, one caveat)
Save as app.cs, then run dotnet run app.cs; the first directive pins the framework.
Caveat — file-based apps disable System.Text.Json reflection. In a
dotnet run app.csfile-based app,JsonSerializer.IsReflectionEnabledByDefaultisfalse, so plain reflection serialization throwsNotSupportedException(NoMetadataForType). Set an explicitTypeInfoResolver = new DefaultJsonTypeInfoResolver()on the options (as below), or use a source-generatedJsonSerializerContext. A regular project does not need this.
// File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
// set <TargetFramework>net11.0</TargetFramework> in the project file instead.
#:property TargetFramework=net11.0
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.PascalCase,
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
};
Console.WriteLine(JsonSerializer.Serialize(new { name = "Jane", age = 30 }, options));
// {"Name":"Jane","Age":30}
Worked example — serialize with typed metadata + PascalCase
The record below uses lowercase member names on purpose, so the PascalCase policy visibly rewrites them in the output:
// File-based app (run: dotnet run app.cs). In a .csproj project, remove this line and
// set <TargetFramework>net11.0</TargetFramework> in the project file instead.
#:property TargetFramework=net11.0
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.PascalCase,
TypeInfoResolver = new DefaultJsonTypeInfoR
Truncated for display — read the full file on GitHub.
Related Skills
Agent-Reach
85.6kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
73.9kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Scrapling
83.9k🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
LocalAI
49.3kLocalAI is the open-source AI engine. Run any model - LLMs, vision, voice, image, video - on any hardware. No GPU required.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
