arXiv:2606.24891cs.PLcs.AI2026-06

用Pydantic和JSON Schema实现建筑能效数据的自动校验

Type Checking Project Haystack Grids using JSON Schema and Pydantic

  • 将Haystack标签文件解析为Python模型,支持静态类型检查
  • 生成可验证的JSON Schema,实现跨系统数据一致性校验
  • 开源工具链降低集成门槛,适合智能建筑开发者使用

本体(Ontology)通过支持互操作性和自动化,使建筑能源服务具备可扩展性。Project Haystack是一种广泛应用的建筑本体,因其灵活的标签式语义模型、开放性和可扩展性而备受青睐,但存在标签使用模糊和自动化验证能力不足的问题。尽管Project Haystack形式上开放,但其依赖源自Haxall生态系统的自定义文件格式和领域专用语言,形成了事实上的集成障碍。本文提出一个基于Python的工具链,包含:(i) 解析Haystack定义文件(Trio文件格式)的解析器;(ii) 从解析结果生成Pydantic模型和JSON Schema的代码生成器。由此生成的模型可在Python中实现静态类型检查与结构校验,而生成的Schema可用于对非Python环境中的JSON表示进行验证。所有工具、生成的模型与Schema均以开源许可证公开,旨在强化Haystack生态系统,并为突破当前技术边界提供实用路径。

原文摘要 · Abstract (English)

Ontologies enable scalable energy services in buildings by supporting interoperability and automation. Project Haystack is a building ontology that is widely adopted due to its flexible, tag-based semantic model, openness, and extensibility, but suffers from ambiguous tag usage and limited automated validation. Although Project Haystack is formally open, its reliance on custom file formats and domain-specific languages that originate from the Haxall ecosystem creates a de facto barrier to integration. In this paper, we address these limitations by introducing a Python-based toolchain for Haystack. We present (i) a parser for Haystack definition files (Trio file format), and (ii) a code generator that derives Pydantic models and JSON Schema definitions from these parsed specifications. The resulting models enable static type checking and enable structural validation of Haystack grids within Python, as well as schema-based validation of JSON representations outside the Python ecosystem. All tools, generated models, and schemas are released publicly under an open-source license, with the goal of strengthening the Haystack ecosystem and opening a practical pathway beyond its current technical boundaries.

建筑能效数据校验PydanticJSON Schema

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。