如何在JSON模式中添加自定义属性?
我如何添加自定义概述并在JSON上进行操作,该操作对自定义 - 托管具有一定的值?
示例:定义要保存到数据库中的JSON中的哪些字段。
示例模式:
{
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer",
"persist":true // To be persisted in DB
},
"productCost": {
"description": "The unique identifier for a product",
"type": "integer",
"persist":false // Not to be persisted in DB
}
},
"required": [ "productCost" ]
}
使用此模式,希望找到“持续存在”的字段:true and of Soserion db。
如果JSON模式对此无效,那么对于此类情况,还应使用什么?
How can I add custom-properties and do operations on the json which have certain value for the custom-property ?
Example : Defining which fields in json to be saved to a database.
Sample schema :
{
"type": "object",
"properties": {
"productId": {
"description": "The unique identifier for a product",
"type": "integer",
"persist":true // To be persisted in DB
},
"productCost": {
"description": "The unique identifier for a product",
"type": "integer",
"persist":false // Not to be persisted in DB
}
},
"required": [ "productCost" ]
}
Using this schema, would like to find the fields which have "persisted":true and persist in Db accordingly.
If JSON schema is not valid approach for this, then what else is supposed to be used for such cases ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,所有未知/自定义关键字作为注释收集;然后,您可以查询评估结果以按数据位置获取注释。您应该为您使用的特定JSON模式评估器查阅文档,以查看如何做到这一点。
All unknown/custom keywords are collected as annotations by default by the implementation; you can then query the evaluation result to get the annotations by data location. You should consult the documentation for the particular JSON Schema evaluator that you are using to see how to do that.