我正在使用 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'属性的用法
发布评论