C# Class से JSON Schema Generator

C# code इनपुट

एडिटर लोड हो रहा है…

JSON Schema आउटपुट

सेटिंग्स

Schema generate करते समय किस class/record को root मानना है, चुनें।

Parsing पूरी तरह आपके ब्राउज़र में चलता है। आपका source कभी भी पेज से बाहर नहीं जाता।

अपने C# DTOs paste करें और तुरंत JSON Schema बनाएँ।

Classes, structs, records, annotations, nullable reference types और generic collections support करता है।

C# classes और records को JSON Schema में कैसे convert करें – step-by-step guide

यह online C# class → JSON Schema converter आपको real models (DTOs, structs और classes) से JSON Schema generate करने में मदद करता है ताकि आप payloads validate कर सकें, contracts share कर सकें और mock JSON generate कर सकें।

  1. स्टेप 1 – अपना C# source paste करें

    • Left editor में वे models paste करें जिन्हें आप document करना चाहते हैं।
    • Referenced types को उसी snippet में शामिल करें ताकि schema definitions generate कर सके।
    • Sample button से example load करें और expected input format देखें।
  2. स्टेप 2 – Root class चुनें (जरूरत हो तो)

    • यदि multiple definitions detect हों, तो अपने API payload से match करने वाला root चुनें।
    • Output schema selected root के around बनता है और referenced types के लिए additional definitions शामिल कर सकता है।
  3. स्टेप 3 – JSON Schema output review करें

    • Types, required vs optional fields, और nested object/array structures check करें।
    • definitions और $ref देखें जब आपके models अन्य models को reference करते हों।
    • Validation, documentation या schema-first development के लिए schema copy/download करें।
  4. स्टेप 4 – Validate करें या mock JSON generate करें

    • Mock Data Generate करें पर क्लिक करके mock generator खोलें (schema preloaded रहेगा)।
    • Breaking changes जल्दी पकड़ने के लिए real payloads को schema के विरुद्ध validate करें।
    • यदि आप advanced schema composition (उदाहरण anyOf/oneOf/allOf) पर निर्भर हैं, तो result को Ajv जैसे full validator से verify करें।

Schema keyword support note

Generated schemas में $ref शामिल हो सकता है और आप इसे edit करके anyOf, oneOf, या allOfजोड़ सकते/सकती हैं। Complex schemas के लिए full JSON Schema validator उपयोग करें और जरूरत हो तो mock generation से पहले dereference करें।

Related JSON Schema & code generation tools

Schemas validate करने, mock payloads बनाने, JSON examples format करने और code व contracts sync रखने के लिए इन tools का उपयोग करें।

अक्सर पूछे जाने वाले सवाल

कौन-से C# constructs supported हैं?

Parser classes, structs, records (primary constructors के साथ), auto-properties, backing fields, enums, और JsonPropertyName/JsonProperty/DataMember(Name=...) जैसी attributes समझता है। यह nullable reference types, optional fields, collections और dictionaries को generated schema में respect करता है।

Types को JSON Schema में कैसे map किया जाता है?

string, bool, int/double/decimal, DateTime/DateOnly/Guid जैसी primitives closest schema type/format में map होती हैं। Arrays, List<T>, IEnumerable<T>, Dictionary<TKey, TValue>, Nullable<T> और T? arrays/objects/optional schema constructs में convert होते हैं। Unknown symbols references बनते हैं जब वे किसी अन्य class/enum से match करते हों।

क्या यह अलग-अलग C# versions और serializers के साथ काम करता है?

हाँ। Records, init-only setters, nullable reference types, System.Text.Json annotations और classic Newtonsoft.Json attributes handle होते हैं। Tool पूरी तरह आपके ब्राउज़र में चलता है—आप proprietary DTOs सुरक्षित रूप से paste कर सकते/सकती हैं।

Mock JSON कैसे generate करूँ?

Schema बनने के बाद "Generate Mock Data" पर क्लिक करें—Mock Generator schema के साथ preloaded खुलेगा। Locales, array counts और optional fields configure करके docs/tests के लिए realistic payloads बनाएँ।

C# Class से JSON Schema Generator | JSONSwiss