重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
json-schema-validator by dkyazzentwatwa/chatgpt-skills
npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill json-schema-validator根据 JSON Schema(草案 7)规范验证 JSON 文档。
from json_validator import JSONValidator
validator = JSONValidator()
# 根据模式验证数据
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "minimum": 0}
},
"required": ["name"]
}
data = {"name": "John", "age": 30}
result = validator.validate(data, schema)
print(f"Valid: {result['valid']}")
# 根据模式验证 JSON 文件
python json_validator.py --data user.json --schema user_schema.json
# 使用内联模式验证
python json_validator.py --data config.json --schema '{"type": "object"}'
# 从样本生成模式
python json_validator.py --generate sample.json --output schema.json
# 批量验证目录
python json_validator.py --data-dir ./configs/ --schema config_schema.json
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
class JSONValidator:
def __init__(self, draft: str = "draft7")
# 验证
def validate(self, data: dict, schema: dict) -> dict
def validate_file(self, data_path: str, schema_path: str) -> dict
def validate_batch(self, data_files: list, schema: dict) -> list
# 模式操作
def generate_schema(self, data: dict) -> dict
def check_schema(self, schema: dict) -> dict
{
"valid": True, # 或 False
"errors": [], # 错误详情列表
"path": "$", # 数据根节点的 JSON 路径
}
# 包含错误时:
{
"valid": False,
"errors": [
{
"message": "'name' 是必需属性",
"path": "$",
"schema_path": "required"
},
{
"message": "-5 小于最小值 0",
"path": "$.age",
"schema_path": "properties.age.minimum"
}
]
}
schema = {
"type": "object",
"properties": {
"id": {"type": "integer"},
"name": {"type": "string", "minLength": 1},
"email": {"type": "string", "format": "email"},
"active": {"type": "boolean", "default": True}
},
"required": ["id", "name", "email"],
"additionalProperties": False
}
schema = {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "integer"},
"value": {"type": "number"}
}
},
"minItems": 1,
"uniqueItems": True
}
schema = {
"type": "object",
"properties": {
"user": {
"type": "object",
"properties": {
"name": {"type": "string"},
"address": {
"type": "object",
"properties": {
"street": {"type": "string"},
"city": {"type": "string"}
}
}
}
}
}
}
validator = JSONValidator()
sample_data = {
"name": "Product A",
"price": 29.99,
"tags": ["electronics", "sale"],
"inStock": True
}
schema = validator.generate_schema(sample_data)
# 返回基于数据类型推断出的模式
type: string, number, integer, boolean, array, object, nullenum: 允许的值const: 精确值minLength, maxLengthpattern: 正则表达式模式format: email, uri, date, date-time, ipv4, ipv6, uuidminimum, maximumexclusiveMinimum, exclusiveMaximummultipleOfitems: 项目的模式minItems, maxItemsuniqueItemscontainsproperties: 属性模式required: 必需属性additionalPropertiesminProperties, maxPropertiespatternPropertiesresult = validator.validate(data, schema)
if not result['valid']:
for error in result['errors']:
print(f"Error at {error['path']}: {error['message']}")
每周安装次数
65
代码仓库
GitHub 星标数
39
首次出现
2026年1月24日
安全审计
安装于
gemini-cli54
codex52
opencode51
cursor49
github-copilot47
claude-code44
Validate JSON documents against JSON Schema (Draft 7) specifications.
from json_validator import JSONValidator
validator = JSONValidator()
# Validate data against schema
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "minimum": 0}
},
"required": ["name"]
}
data = {"name": "John", "age": 30}
result = validator.validate(data, schema)
print(f"Valid: {result['valid']}")
# Validate JSON file against schema
python json_validator.py --data user.json --schema user_schema.json
# Validate with inline schema
python json_validator.py --data config.json --schema '{"type": "object"}'
# Generate schema from sample
python json_validator.py --generate sample.json --output schema.json
# Batch validate directory
python json_validator.py --data-dir ./configs/ --schema config_schema.json
class JSONValidator:
def __init__(self, draft: str = "draft7")
# Validation
def validate(self, data: dict, schema: dict) -> dict
def validate_file(self, data_path: str, schema_path: str) -> dict
def validate_batch(self, data_files: list, schema: dict) -> list
# Schema operations
def generate_schema(self, data: dict) -> dict
def check_schema(self, schema: dict) -> dict
{
"valid": True, # or False
"errors": [], # List of error details
"path": "$", # JSON path to data root
}
# With errors:
{
"valid": False,
"errors": [
{
"message": "'name' is a required property",
"path": "$",
"schema_path": "required"
},
{
"message": "-5 is less than minimum 0",
"path": "$.age",
"schema_path": "properties.age.minimum"
}
]
}
schema = {
"type": "object",
"properties": {
"id": {"type": "integer"},
"name": {"type": "string", "minLength": 1},
"email": {"type": "string", "format": "email"},
"active": {"type": "boolean", "default": True}
},
"required": ["id", "name", "email"],
"additionalProperties": False
}
schema = {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {"type": "integer"},
"value": {"type": "number"}
}
},
"minItems": 1,
"uniqueItems": True
}
schema = {
"type": "object",
"properties": {
"user": {
"type": "object",
"properties": {
"name": {"type": "string"},
"address": {
"type": "object",
"properties": {
"street": {"type": "string"},
"city": {"type": "string"}
}
}
}
}
}
}
validator = JSONValidator()
sample_data = {
"name": "Product A",
"price": 29.99,
"tags": ["electronics", "sale"],
"inStock": True
}
schema = validator.generate_schema(sample_data)
# Returns inferred schema based on data types
type: string, number, integer, boolean, array, object, nullenum: allowed valuesconst: exact valueminLength, maxLengthpattern: regex patternformat: email, uri, date, date-time, ipv4, ipv6, uuidminimum, maximumexclusiveMinimum, exclusiveMaximummultipleOfitems: schema for itemsminItems, maxItemsuniqueItemscontainsproperties: property schemasrequired: required propertiesadditionalPropertiesminProperties, maxPropertiespatternPropertiesresult = validator.validate(data, schema)
if not result['valid']:
for error in result['errors']:
print(f"Error at {error['path']}: {error['message']}")
Weekly Installs
65
Repository
GitHub Stars
39
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli54
codex52
opencode51
cursor49
github-copilot47
claude-code44
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
122,000 周安装
通用项目发布工具 - 多语言更新日志自动生成 | 支持Node.js/Python/Rust/Claude插件
62 周安装
Edge Pipeline Orchestrator:自动化金融交易策略流水线编排工具
62 周安装
Python ROI 计算器:投资回报率、营销ROI、盈亏平衡分析工具
62 周安装
Salesforce Hyperforce 2025架构指南:云原生、零信任安全与开发最佳实践
62 周安装
PowerShell 2025 重大变更与迁移指南:版本移除、模块停用、WMIC替代方案
62 周安装
2025安全优先Bash脚本编写指南:输入验证、命令注入与路径遍历防护
62 周安装