JSON模式中'$ id'属性的用法

编程入门 行业动态 更新时间:2024-10-27 20:37:48
本文介绍了JSON模式中'$ id'属性的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 JSON模式来验证数据.

I'm using JSON Schema for validating data.

我认为使用保留关键字$ id可能会使我的模式出现错误.该字段的目的是指定另一个平台上该属性的REMOTE ID.因此,这就是来源ID".

I think that I may have a mistake on my schema by using the reserved keywords $id. The intention of this field was to designate what the REMOTE ID of the property on another platform was. So it was the "origin ID".

您能告诉我$ id是什么吗,如果我犯了一个严重错误并且此值需要更改.因为在文档中我找到了这个定义:

Can you please advise what $id is and if I have made a critical mistake and this value needs changing. Because in the documentation I have found this definition:

如果存在,则此关键字的值必须为字符串,并且必须表示有效的URI引用[RFC3986].该值应该被规范化,并且不应该是一个空的片段<#>或一个空的字符串<>.

If present, the value for this keyword MUST be a string, and MUST represent a valid URI-reference [RFC3986]. This value SHOULD be normalized, and SHOULD NOT be an empty fragment <#> or an empty string <>.

推荐答案

$ id是保留关键字.

$id is a reserved keyword.

它用于:

  • 声明模式或子模式的标识符
  • 声明用于解析$ ref URL的基本URL

您可以使用$ id标识模式或模式的一部分(子模式),然后可以使用$ ref关键字在其他地方重用它.看到这种情况的最简单方法是,将$ ref替换为具有相应ID的架构.

You can identify a schema, or a part of your schema (a subschema) by using $id, and then you can reuse it somewhere else by using the $ref keyword. The most simple way of seeing this, is that the $ref would be replaced by the schema with the corresponding id.

  • tools.ietf/html/draft-wright-json-schema-01#section-9.2

更多推荐

JSON模式中'$ id'属性的用法

本文发布于:2023-11-09 09:09:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571989.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   模式   JSON   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!