<p>JSON模式是基于约束的,而不是基于权限的。
空的JSON模式<code>{}</code>表示任何内容都是有效的</p>
<P>让我们看看关键字^ {< CD2>}添加了什么约束…<p>
<blockquote>
<p>Validation succeeds if, for each name that appears in both the<br/>
instance and as a name within this keyword's value, the child<br/>
instance for that name successfully validates against the<br/>
corresponding schema.</p>
<p>Omitting this keyword has the same behavior as an empty object.</p>
</blockquote>
<p><a href="https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5.4" rel="nofollow noreferrer">https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5.4</a></p>
<p>这意味着<code>properties</code>对象中键的值的模式适用于JSON实例中的相应值</p>
<p>以你为例:</p>
<pre><code>...
"properties" : {
"pltfrm_nm": {"type" : "string"}
}
...
</code></pre>
<p><code>pltfrm_nm</code>必须是字符串</p>
<p>这是上面的讽刺暗示的唯一约束</p>
<p>是否希望未在<code>proprties</code>中列出的键会导致验证错误?
如果是这样,您需要指定该事实</p>
<p>要在<code>properties</code>中定义的属性之外不指定其他属性,需要使用<code>additionalProperties</code></p>
<p><a href="https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5.6" rel="nofollow noreferrer">https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5.6</a></p>
<p>我建议您浏览一下我们在<a href="http://json-schema.org/understanding-json-schema/" rel="nofollow noreferrer">http://json-schema.org/understanding-json-schema/</a>和<a href="http://json-schema.org/understanding-json-schema/" rel="nofollow noreferrer">http://json-schema.org/understanding-json-schema/</a>的学习资源,了解JSON模式的介绍</p>