ഓൺലൈൻ JSON മുതൽ JSON സ്കീമ ജനറേറ്റർ
ప్రത്യേകം, സ്റ്റാൻഡേർഡ് പാലിച്ച JSON സ്കീമ യാഥാർത്ഥ്യ JSON ഇൽനിന്ന് ഉടൻ, സുരക്ഷിതമായി, സൗജന്യമായി സൃഷ്ടിക്കുക.
ഈ ഉപകരണം JSON സാമ്പിള് എടുത്ത്, അതിന്റെ ഘടന, ഡാറ്റ ടൈപ്പുകൾ, നിയന്ത്രണങ്ങൾ എന്നിവ കൃത്യമായി പ്രതിഫലിപ്പിക്കുന്ന JSON സ്കീമ ഡRAFT-07 ഡോക്യുമെന്റ് സൃഷ്ടിക്കുന്നു. എല്ലാ പ്രോസസ്സ് ബ്രൗസറിലുള്ളതാണ്, പൂർണ സ്വകാര്യത ഉറപ്പ്. ഡാറ്റ അപ്ലോഡ് ചെയ്യപ്പെടുകയോ സൂക്ഷിക്കുകയോ ചെയ്യാറില്ല. API ഡോക്യുമെന്റേഷൻ, സാധുത പരിശോധന, കോഡ് ജനറേഷൻ എന്നിവയ്ക്ക് അനുയോജ്യം.
താഴെ JSON നു JSON സ്കീമയ്ക്കുള്ള മാറ്റം
സ്കീമ ജനറേഷന്റെ പിന്നിലെ പ്രവർത്തനം
സാമ്പിൾ JSON നിന്നും JSON സ്കീമ സൃഷ്ടിക്കുന്നത് മേഖലകളെ ടൈപ്പുകളോട് മാത്രമല്ല, കുറച്ച് പ്രധാന ഘട്ടങ്ങൾക്കുറി കൃത്യതയ്ക്കും സമഗ്രതയ്ക്കും ഈ ടൂൾ ഉപയോഗിക്കുന്നു:
- പരിശോധന: ECMA-404 അനുസരിച്ച് നിങ്ങളുടെ JSON പാഴ്സ് ചെയ്യുന്നു, തെറ്റുകൾക്ക് വിശദമായ റിപ്പോർട്ടുകൾ നൽകുന്നു.
- ഘടനാ വിശകലനം: JSON സ്കീമയുടെ പ്രാഥമിക ടൈപ്പുകൾ (object, array, string, number, integer, boolean, null) അനുസരിച്ച് നിങ്ങളുടെ ഡാറ്റയുടെ തരം തിരിച്ചറിയുന്നു.
- പുനരാവൃത്തി യാത്ര: നേർവഴികളും nests ഉൾപ്പെടെയുള്ള ഘടനകൾ പുനരാവൃത്തി പാതയിലൂടെ കണ്ടുപിടിക്കുന്നു, നെസ്റ്റഡ് സ്കീമ നിർവചനങ്ങൾ സൃഷ്ടിക്കുന്നു.
- ടൈപ്പ് ഇൻഫെറൻസ് & മേഴ്ജിംഗ്: ഓരോ പ്രോപർട്ടി / അറേ ഇലമെന്റിനും ടൈപ്പ് നിർണ്ണയിക്കുന്നു; മിക്സഡ് ടൈപ്പുകൾ ഉണ്ടെങ്കിൽ JSON സ്കീമ പ്രതിപാദനാനുസരിച്ച് 'type' ആണ് അരേ ആയി പ്രദർശിപ്പിക്കുക.
- ആവശ്യകത vs നിർബന്ധമല്ലാത്തത്: എല്ലാ ഓബ്ജക്റ്റുകളിലും നിന്ന് മൂല്യനിർണ്ണയം നടത്തി എപ്പോഴും കാണപ്പെടുന്ന (ആവശ്യമായ) വിവരങ്ങളും കോൺഡിഷണൽ (ഐച്ഛിക) വിവരങ്ങളും വേർതിരിക്കുന്നു.
- മൂല്യ നിയന്ത്രണങ്ങൾ: എനംസുകൾ, min/max നമ്പറുകൾ, minLength/maxLength സ്ട്രിംഗുകൾ, ഫോർമാറ്റ് സൂചനകൾ (email, uri, date-time തുടങ്ങിയവ) എന്നിവ നിർദ്ദേശിക്കും.
- അസാധാരണ കേസുകളുടെ കൈകാര്യം: ശൂന്യ അറേകൾ, നൾ മൂല്യങ്ങൾ, അപൂർണ്ണ ഘടനകൾ എന്നിവയ്ക്ക് പ്രത്യേക ശ്രദ്ധ, യാഥാർത്ഥ്യ വ്യത്യാസങ്ങൾക്ക് അനുസരിക്കാനുള്ള സാധുവായ സ്കീമ ഉറപ്പ്.
- സ്കീമ സംയോജനം: അന്തിമ സ്കീമ സ്റ്റാൻഡേർഡ് അനുസരിച്ചുള്ള ഡRAFT-07 ഡോക്യുമെന്റായി പുറപ്പെടുന്നു — Ajv, OpenAPI, കോഡ് ജനറേഷൻ ലൈബ്രറികൾക്കായി ഉപയോഗിക്കാൻ തയ്യാറായിരിക്കും.
JSON സ്കീമ ജനറേറ്റ് ചെയ്യേണ്ടതെന്തിന്? പ്രായോഗിക ഉപയോഗങ്ങൾ
- സ്വയംചാലിത സാധുത പരിശോധന: സൃഷ്ടിച്ച സ്കീമ ഉപയോഗിച്ച് ഡാറ്റാ കരാറുകൾ ഉറക്കി നിങ്ങളുടെ APIകൾ, മൈക്രോസെർവിസുകൾ, CLIകൾ മുതലായവയ്ക്ക് പെയ്ലോഡ് സാധുത പരിശോധന നടത്താം.
- API ഡോക്യുമെന്റേഷൻ: കൃത്യമായ ഡാറ്റ നിർവചനങ്ങളോടെ സ്വയം സൃഷ്ടിക്കുന്ന ഡോക്യുമെന്റും സംവേദനാത്മക എക്സ്പ്ലോററും (Swagger, Postman) സൃഷ്ടിക്കുക.
- കോഡ് ജനറേഷൻ: ടൈപ്പ്-സേഫ് മോഡലുകളും വാലിഡേറ്ററുകളും TypeScript, Python, Java മുതലായ ഭാഷകളിൽ സൃഷ്ടിക്കാൻ നിങ്ങളുടെ സ്കീമ ഒറ്റ സ്രോതസ്സായി ഉപയോഗിക്കുക.
- ടെസ്റ്റ് ഡാറ്റ ജനറേഷൻ: JSON Schema Faker, Mockaroo പോലുള്ള ഉപകരണങ്ങൾ സ്കീമ ഉപയോഗിച്ച് യാഥാർത്ഥ്യത്തിന് സാദൃശ്യമായ മോക്ക് ഡാറ്റ സൃഷ്ടിക്കുന്നു.
- പുനഃസംഘടന & മൈഗ്രേഷൻ: പൈതൃകമോ മാറ്റങ്ങളോ ഉള്ള ഡാറ്റാ ഘടനകൾ സാധുത പരിശോധന ചെയ്ത് നിങ്ങളുടെ ബാക്ക്എൻഡ് വികസനത്തിനൊത്ത് പൊരുത്തം ഉറപ്പാക്കുക.
സാങ്കേതിക സവിശേഷതകൾ
- ഡRAFT-07 പൊരുത്തക്കുറുക്കിനായി പ്രധാന വാലിഡേറ്ററുകൾക്കും API ഡിസൈൻ പ്ലാറ്റ്ഫോമുകൾക്കും അനുയോജ്യം.
- ഏതൊരു നിവാരണത്തിന്റെയും പുനരാവൃത്തവുമായി വിശകലനം — അറേയുകൾ അറേയിനുള്ളിൽ, objects അറേയിനുള്ളിൽ, അതിനുമേൽ.
- മാറ്റിമറിക്കുന്ന ഉദാഹരണങ്ങളിലേക്കുള്ള ഫീൽഡുകൾക്കും ഇനങ്ങൾക്കുമുള്ള ശരിയായ യൂണിയൻ ടൈപ്പ് ('type' അരേ) നിർണ്ണയം.
- എനം, നീളം, പാറ്റേൺ, ഫോർമാറ്റ്, min/max, മറ്റു ധാരാളം സാധാരണ നിയന്ത്രണങ്ങൾ സ്വയം തിരിച്ചറിയൽ.
- നൾ, ശൂന്യ അറേയുകളും ഓബ്ജക്റ്റുകളും ഭാഗിക രേഖകളും വ്യക്തമായി പിന്തുണ.
- സ്കീമ ജനറേഷൻ മുഴുവനായും ബ്രൗസറിൽ നടക്കുന്നു. നിങ്ങളുടെ ഇൻപുട്ട് JSON നിങ്ങളുടെ ഉപകരണത്തിൽ നിന്നും പുറത്ത് പോകാറില്ല.
സാങ്കേതിക ഉദാഹരണം: സാമ്പിൾ JSON നിന്ന് ഡRAFT-07 സ്കീമ വരെ
സാമ്പിൾ JSON ഇൻപുട്ട്
{ "transaction": { "id": "txn_abc123", "amount": 99.95, "currency": "USD", "status": "completed", "meta": { "ip": "203.0.113.1", "tags": ["recurring", null] } }, "refunded": false, "notes": null }സൃഷ്ടിച്ച JSON സ്കീമ ഔട്ട്പുട്ട്
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "transaction": { "type": "object", "properties": { "id": { "type": "string" }, "amount": { "type": "number" }, "currency": { "type": "string", "minLength": 3, "maxLength": 3 }, "status": { "type": "string", "enum": ["completed"] }, "meta": { "type": "object", "properties": { "ip": { "type": "string", "format": "ipv4" }, "tags": { "type": "array", "items": { "type": ["string", "null"] } } }, "required": ["ip", "tags"] } }, "required": ["id", "amount", "currency", "status", "meta"] }, "refunded": { "type": "boolean" }, "notes": { "type": ["null"] } }, "required": ["transaction", "refunded", "notes"] }
ഈ JSON മുതൽ JSON സ്കീമ ടൂൾ എങ്ങനെ ഉപയോഗിക്കാം
- താഴെയുള്ള എഡിറ്ററിൽ നിങ്ങളുടെ ഉദാഹരണ JSON പേസ്റ്റ് ചെയ്യുക അല്ലെങ്കിൽ ടൈപ്പ് ചെയ്യുക. എളുപ്പമോ സങ്കീർണ്ണമോ ആയ യാതൊരു സാധുവായ JSON-ഉം ഈ ടൂൾ സ്വീകരിക്കുന്നു.
- 'JSON സ്കീമ സൃഷ്ടിക്കുക' ക്ലിക്ക് ചെയ്തു സൃഷ്ടിച്ച JSON സ്കീം കാണുക.
- സ്കീമ കോപ്പി ചെയ്യുക, എഡിറ്റ് ചെയ്യുക, ഡൗൺലോഡ് ചെയ്ത് നേരിട്ട് നിങ്ങളുടെ API നിർവചനങ്ങളിൽ, സാധുത ബോധിപ്പിക്കൽ ലൊജിക്കിൽ അല്ലെങ്കിൽ ഡോക്യുമെന്റേഷനിൽ ഉപയോഗിക്കുക.
JSON-ൽ നിന്ന് സ്കീമ സംഭരണം സൃഷ്ടിക്കാൻ കോഡ് ഉദാഹരണങ്ങൾ
വിവിധ പ്രോഗ്രാമിങ് ഭാഷകളിൽ JSON മുതൽ JSON Schema എങ്ങനെ സൃഷ്ടിക്കാമെന്ന് കാണൂ.
JavaScript (Node.js)
Install: npm install jsonschema-generator
const generateSchema = require('jsonschema-generator');
const data = {
name: "Alice",
age: 30,
isActive: true,
tags: ["user", "admin"]
};
const schema = generateSchema(data);
console.log(JSON.stringify(schema, null, 2));
JavaScript (Node.js) with generate-schema
Install: npm install generate-schema
const GenerateSchema = require('generate-schema');
const data = { name: "Alice", age: 30, tags: ["admin", "user"] };
const schema = GenerateSchema.json('User', data);
console.log(JSON.stringify(schema, null, 2));
Python with genson
Install: pip install genson
from genson import SchemaBuilder
sample = {"name": "Alice", "age": 30, "tags": ["user", "admin"]}
builder = SchemaBuilder()
builder.add_object(sample)
print(builder.to_json(indent=2))
Python with jsonschema-generate
Install: pip install jsonschema-generate
from jsonschema_generate import generate_schema
sample = {"name": "Alice", "age": 30, "tags": ["user", "admin"]}
schema = generate_schema(sample)
print(schema)
Go
Install: go get github.com/invopop/jsonschema
package main
import (
"encoding/json"
"fmt"
"github.com/invopop/jsonschema"
)
type User struct {
Name string `json:"name"
Age int `json:"age"
Tags []string `json:"tags"
}
func main() {
schema := jsonschema.Reflect(&User{})
out, _ := json.MarshalIndent(schema, "", " ")
fmt.Println(string(out))
}
Java with jsonschema2pojo (CLI/Gradle/Maven)
Install: jsonschema2pojo CLI or plugin (see https://www.jsonschema2pojo.org/)
# Generate Java POJOs *from* a JSON Schema, not the reverse.
# For schema generation from Java, see tools like jackson-module-jsonSchema.
# See: https://github.com/FasterXML/jackson-module-jsonSchema
C# with NJsonSchema
Install: dotnet add package NJsonSchema
using NJsonSchema;
using Newtonsoft.Json.Linq;
var sample = JObject.Parse("{\"name\":\"Alice\",\"age\":30, \"tags\":[\"user\"]}");
var schema = await JsonSchema.FromSampleJsonAsync(sample.ToString());
Console.WriteLine(schema.ToJson());
PHP with swaggest/json-schema
Install: composer require swaggest/json-schema
require 'vendor/autoload.php';
use Swaggest\JsonSchema\Structure\ClassStructure;
$sample = ["name" => "Alice", "age" => 30, "tags" => ["user"]];
$schema = ClassStructure::exportSchema($sample);
echo json_encode($schema, JSON_PRETTY_PRINT);
Ruby with json_schemer
Install: gem install json_schemer
require 'json_schemer'
sample = { "name" => "Alice", "age" => 30, "tags" => ["admin", "user"] }
schema = JSONSchemer.schema(sample)
puts schema.to_json
Bash (with Python genson)
Install: pip install genson
echo '{"name":"Alice","age":30,"tags":["user","admin"]}' | genson | jq .
Rust with schemars
Install: cargo add schemars
use schemars::JsonSchema;
use serde::Serialize;
#[derive(Serialize, JsonSchema)]
struct User {
name: String,
age: u32,
tags: Vec<String>,
}
fn main() {
let schema = schemars::schema_for!(User);
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
}
Scala with com.github.andyglow:jsonschema
Install: libraryDependencies += "com.github.andyglow" %% "jsonschema" % "0.7.7"
import json.schema._
case class User(name: String, age: Int, tags: List[String])
val schema = Json.schema[User]
println(schema.asSpray.prettyPrint)
TypeScript with typescript-json-schema
Install: npm install -g typescript-json-schema
# Generate schema from a TypeScript interface:
typescript-json-schema tsconfig.json User --out schema.json
# See https://github.com/YousefED/typescript-json-schema
Dart (manual, no auto-inference)
Install: None (write schema manually)
// Dart does not have an automatic JSON Schema generator yet.
// Manually define schema as a Dart Map or use online tools.