JSON (JavaScript Object Notation) is a data encoding that allows structured data to be used in a standardized and straightforward manner across systems. Schemas for JSON-formatted data can be constructed using the JSON Schema standard, which describes the data types, structure, and meaning of JSON-formatted data. JSON is commonly used for storing and transmitting information such as program configurations, web API requests and responses, or remote procedure calls; or data records, such as healthcare information or other structured documents. Since JSON is a plaintext format with potentially highly complex definitions, it can be an arduous process to change code which handles structured JSON data when its storage or transmission schemas are modified. Our work describes a program synthesis method to generate a program that accepts data conforming to a given input JSON Schema and automatically converts it to conform to a resulting, target JSON Schema. We use a top-down, type-directed approach to search for programs using a set of rewrite rules which constrain the ways in which a schema can be modified without unintended data loss or corruption. Once a satisfying sequence of rewrites has been found, we pass an intermediate representation of the rewrite sequence to a code generation backend, which synthesizes a program which executes the data transformation. This system allows users to quickly and efficiently modify or augment their existing systems in safe ways at their interfaces.
翻译:JSON(JavaScript Object Notation)是一种数据编码格式,允许结构化数据在系统间以标准化且简明的方式使用。针对JSON格式数据的模式可通过JSON Schema标准构建,该标准描述了JSON格式数据的类型、结构及语义。JSON通常用于存储和传输程序配置、网络API请求与响应或远程过程调用等信息,亦可用于医疗记录等结构化文档的数据记录。由于JSON是纯文本格式且可能具有高度复杂的定义,当存储或传输模式发生变更时,修改处理结构化JSON数据的代码可能成为繁琐的过程。本研究提出一种程序合成方法,用于生成能够接收符合给定输入JSON Schema的数据,并自动将其转换为符合目标JSON Schema的程序。我们采用自顶向下、类型导向的方法,通过一组重写规则搜索程序,这些规则限定了模式修改方式以避免非预期的数据丢失或损坏。当找到满足条件的重写序列后,我们将该序列的中间表示传递给代码生成后端,进而合成执行数据转换的程序。该系统使用户能够在接口层面以安全、快速、高效的方式修改或扩展现有系统。