中文

现代 JSON Schema 验证中标注依赖的消除

数据库 2025-03-17 v1 编程语言

摘要

JSON Schema 是一种用于定义 JSON 值结构的逻辑语言。JSON Schema 语法基于嵌套的 schema 对象。在直至 Draft-07 的所有 JSON Schema 版本中(统称为经典 JSON Schema),schema 的语义完全由其验证的 JSON 值集合所描述。该语义为深入的理论研究以及开发用于判定 schema 可满足性与等价性的工具奠定了基础。遗憾的是,经典 JSON Schema 在表达对象 schema 扩展方面存在严重局限,这促使 Draft 2019-09 引入了两项颠覆性特性:标注依赖与动态引用。这些新特性破坏了先前建立的语义理论,且用于判定经典 JSON Schema 可满足性的算法难以扩展。一种可能的解决方案是将用现代 JSON Schema 编写的 schema 重写为等价的传统 JSON Schema。在本文中,我们证明,消除标注依赖关键词通常无法避免 schema 规模的指数级增长。我们提供了一种消除这些关键词的算法,尽管存在理论下界,但该算法在实际应用中表现良好,这一点已通过大量实验验证。

关键词

引用

@article{arxiv.2503.11288,
  title  = {Elimination of annotation dependencies in validation for Modern JSON Schema},
  author = {Lyes Attouche and Mohamed-Amine Baazizi and Dario Colazzo and Giorgio Ghelli and Stefan Klessinger and Carlo Sartiani and Stefanie Scherzinger},
  journal= {arXiv preprint arXiv:2503.11288},
  year   = {2025}
}