json - 基于两个 JSONSchema 为实例数据生成 JSONPatch
问题描述
我搜索了一个允许从两个JSONSchema生成JSONPatch的工具。例子:
JSONSchema A:
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
}
JSON对象可以在哪里:
{"firstName": "John", "lastName": "Doe", "age": 42 }
JSONSchema B(无年龄):
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
}
}
}
生成的 JSONPatch 应该是:
[
{ "op": "remove", "path": "/age" }
]
要在应用补丁后获取,对象:
{"firstName": "John", "lastName": "Doe" }
有一些工具吗?
解决方案
推荐阅读
- regex - 在一组字符和一些整数之后获取第一个字母的正则表达式是什么?
- java - 在 AnyLogic 中执行存活率计算
- android - 在根目录中运行 make 命令时如何在不同的目录中运行可执行文件?
- python - 如何将创建的文件移动到刚刚创建的目录中?
- c# - C#如何获取2个单独的类值节点并将它们写入数据表/dgv
- pivot - 计算平均值:基于另一列 Excel 数据透视表和 PowerBI 中的唯一值的最大值
- django - API 不发送电子邮件
- r - 使用 R odbc 包将日期插入 Oracle 时时区偏移和丢失毫秒
- javascript - 多级侧边栏菜单,如 Glazed Main
- authentication - 如何将 bcrypt 嵌入到 mongose API 调用中?