मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)5.8k · #14656

system-text-json-net11

यह क्या करती है

यह स्किल .NET 11 के तीन नए JSON फ़ीचर दिखाती है: PascalCase नामकरण का बिल्ट-इन विकल्प, और JSON टाइप-इन्फ़ो के लिए टाइप्ड लुकअप। यह .NET 11 पर C# में JSON के साथ काम करने वाले डेवलपर्स के लिए है।

कब इस्तेमाल करें

  • ✓जब .NET 11 ऐप को कस्टम नामकरण नीति लिखे बिना JSON प्रॉपर्टी नाम PascalCase में चाहिए।
  • ✓जब कोड GetTypeInfo को कॉल करके नतीजे को टाइप्ड JsonTypeInfo में कास्ट करता है।
  • ✓जब आपको JSON टाइप उपलब्ध है या नहीं, यह try और catch में लपेटे बिना जाँचना हो।

Skill का लिंक

https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/system-text-json-net11/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/system-text-json-net11/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे .NET 11 ऐप में अपने मॉडल्स को बिना कस्टम नामकरण कोड के PascalCase प्रॉपर्टी नामों वाले JSON में सीरियलाइज़ कीजिए।”

हर हफ़्ते 5 नई skills, 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:

  1. Run dotnet --list-sdks and confirm an SDK that can target net11.0 is present — an 11.x SDK, or a later SDK with the net11.0 targeting pack.
  2. If the user explicitly asks you to run the sample and no suitable SDK is installed, use the official dotnet-install script 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-wide PATH, or replace an installed SDK.
  3. Run the sample with that local dotnet executable. If download or execution is blocked, still provide the complete net11.0 program and report that it was not run. Never substitute net10.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:

  1. Create or reuse a JsonSerializerOptions and set PropertyNamingPolicy = JsonNamingPolicy.PascalCase.
  2. 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
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills