简体   繁体   English

marklogic 中的 JSON 模式验证

[英]JSON schema validation in marklogic

I was trying to validate simple JSON document against a JSON schema in query console having a query type "javascript" but i am getting an error.我试图在具有查询类型“javascript”的查询控制台中针对 JSON 模式验证简单的 JSON 文档,但出现错误。

Schema validation code :-架构验证代码:-

xdmp.jsonValidateNode(
      { "count": 3, "items": [12] }, 
      {
        "properties": {
           "count": { "type":"integer", "minimum":0 },
           "items": { "type":"array", "items": {"type":"string", "minLength":1 } }
         }
      })

Error :-错误 :-

[javascript] JS-JAVASCRIPT: xdmp.jsonValidateNode( -- Error running JavaScript request: TypeError: xdmp.jsonValidateNode is not a function Stack Trace At line 1 column 5: In xdmp.jsonValidateNode( [javascript] JS-JAVASCRIPT: xdmp.jsonValidateNode( -- Error running JavaScript request: TypeError: xdmp.jsonValidateNode is not a function Stack Trace At line 1 column 5: In xdmp.jsonValidateNode(

  1. xdmp.jsonValidateNode( xdmp.jsonValidateNode(
  2. { "count": 3, "items": [12] }, { "count": 3, "items": [12] },

This is marklogic supported function.这是 marklogic 支持的功能。 How it is throwing not a fnction error.它是如何抛出不是功能错误的。

Also, is there any other way to validate json document against json schema in marklogic ?另外,还有其他方法可以根据 marklogic 中的 json 模式验证 json 文档吗?

xdmp.jsonValidateNode() is a newer function. xdmp.jsonValidateNode()是一个较新的函数。 You will need to upgrade to a later 9.0 release.您需要升级到更高的 9.0 版本。

Executing your snippet in 9.0-9.1 works and returns a validation error:在 9.0-9.1 中执行您的代码段有效并返回验证错误:

[javascript] XDMP-JSVALIDATEINVTYPE: xdmp.jsonValidateNode( -- Invalid node type: Expected node of type text, found number at NumberNode(12) using schema "" [javascript] XDMP-JSVALIDATEINVTYPE: xdmp.jsonValidateNode( -- 无效的节点类型:文本类型的预期节点,在 NumberNode(12) 处使用架构“”找到编号

I recommend upgrading to the latest 9.0 release (currently 9.0-11) or MarkLogic 10我建议升级到 最新的 9.0 版本(当前是 9.0-11)或MarkLogic 10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM