JSON से JSON Schema जनरेटर
Example
Input:
{"name": "Ali", "age": 30}Output:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
},
"required": [
"name",
"age"
]
}इस converter के बारे में
एक sample से inferred schema ज्ञात blind spots वाला एक starting point है, और यह generator उनके बारे में ईमानदार है: मौजूद हर key required बन जाती है (दूसरा sample कुछ को optional साबित कर सकता है), numbers sample की shape से integer या number बनते हैं, और एक single value से कोई constraints (minLength, pattern, enum) inferred नहीं हो सकते। आपको जो मिलता है वह structural skeleton है — types, nesting, array item shapes — जो किसी API को document करने या validation setup करने में typing का 90% है, आपके लिए तैयार कि आप required lists को ढीला करें और वे constraints जोड़ें जो सिर्फ़ इंसान जानता है।
अक्सर पूछे जाने वाले सवाल
हर property required क्यों है?
एक sample से inference यह नहीं जान सकता कि कोई key optional है। Merge करने वाले tools को varied samples की array दें, या required list को हाथ से trim करें।
कौन सा draft generated होता है?
JSON Schema 2020-12, वर्तमान release; structure इन basic keywords के लिए draft-07 consumers के साथ भी compatible है।