system-text-json-net11
하는 일
이 스킬은 .NET 11의 새 JSON 기능 세 가지를 쓰는 방법을 보여 줍니다. 내장 PascalCase 이름 옵션과 JSON 타입 정보의 타입 지정 조회가 있습니다. .NET 11에서 C#으로 JSON을 다루는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓.NET 11 앱에서 사용자 정의 이름 정책을 쓰지 않고 JSON 속성 이름을 PascalCase로 하고 싶을 때.
- ✓GetTypeInfo를 호출한 뒤 결과를 타입 지정된 JsonTypeInfo로 캐스팅할 때.
- ✓try와 catch로 감싸지 않고 JSON 타입이 있는지 확인해야 할 때.
스킬 링크
https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/system-text-json-net11/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 .NET 11 앱에서 사용자 정의 이름 코드 없이 모델을 PascalCase 속성 이름의 JSON으로 직렬화해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트가 직렬화 옵션에 내장 PascalCase 이름 정책을 설정하고, 필요한 곳에 타입 지정 조회 메서드를 쓰며, 코드를 실행해 출력을 보여 줍니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
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
자주 묻는 질문
.NET 10에서도 되나요?
아니요. 이 API는 .NET 11 기본 라이브러리에만 있습니다.
새 SDK를 설치하나요?
샘플을 실행하라고 요청했는데 맞는 .NET 11 SDK가 없으면 설치할 수 있습니다.
try-get 조회는 무엇을 대체하나요?
타입이 있는지 확인하려고 조회를 try와 catch로 감싸던 방식을 대체합니다.
상세 정보
작성자의 원본 설명
Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). 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 generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serializat
repo: dotnet/skills
인기도
- GitHub 스타
- 5.8k
- 순위
- #14656
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
create-custom-agent
5.8k에이전트가 자체 도구, 지침, 다른 에이전트로의 핸드오프를 가진 VS Code 커스텀 에이전트 파일을 만들도록 돕습니다.
create-skill
5.8k에이전트가 올바른 이름, 명확한 트리거 설명, 표준을 따르는 SKILL.md 파일로 새 에이전트 스킬을 만들도록 돕습니다.
csharp-scripts
5.8k에이전트가 .NET 명령줄 도구로 작은 C# 프로그램을 전체 프로젝트 없이 단일 파일로 실행하도록 돕습니다.
dotnet-pinvoke
5.8k에이전트가 .NET에서 네이티브 C나 C++ 라이브러리를 올바르게 호출하도록 돕습니다. 시그니처, 문자열 처리, 메모리, 안전 핸들을 다룹니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.