如何在JSON模式中添加自定义属性?

发布于 2025-02-13 02:16:58 字数 596 浏览 0 评论 0原文

我如何添加自定义概述并在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹉夏雨初晴づ 2025-02-20 02:16:58

默认情况下,所有未知/自定义关键字作为注释收集;然后,您可以查询评估结果以按数据位置获取注释。您应该为您使用的特定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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文