【问题标题】:JSON Schema Validation Error in MarkLogic - XDMP-VALIDATEERRORSMarkLogic 中的 JSON 模式验证错误 - XDMP-VALIDATEERRORS
【发布时间】:2021-11-17 04:53:19
【问题描述】:

使用 MarkLogic 10.0-4.2 版,我正在尝试根据简单的 JSON 模式验证简单的 JSON 记录。

JSON 架构:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "SourceSystemName": {
        "type": "string"
    },
    "BatchDtTm": {
        "type": "string"
    },
    "SubjectArea": {
        "type": "string"
    },
    "DocumentType": {
        "type": "string"
    },
    "LastUpdatedDt": {
        "type": "string"
    },
  "required": [
    "SourceSystemName",
    "BatchDtTm",
    "SubjectArea",
    "DocumentType",
    "LastUpdatedDt",
  ]
  }
}

在查询控制台中运行的代码:

let jsonRecord = {"SourceSystemName":"ODH","BatchDtTm":"09/17/21 08:51:48:472723","SubjectArea":"Customer","DocumentType":"Preference","LastUpdatedDt":"09/17/21 03:59:53:629707"};

xdmp.jsonValidate(jsonRecord, cts.doc('/schemas/NewSchema.json').toString());

当我运行上面的代码时,我得到了错误 XDMP-JSVALIDATEBADSCHEMA:无效架构“”:“”

我不太确定我的架构是什么“无效”。有人可以提供一些关于 MarkLogic 将什么视为“无效”的见解吗?

【问题讨论】:

  • 您的架构"LastUpdatedDt",required 数组中有一个尾随逗号

标签: json schema marklogic marklogic-10


【解决方案1】:

$schema 的第二个参数应该是架构文档的 URI。

用于验证的 JSON 模式的 $schema URI。

您正在尝试传入字符串化的内容。

试试:

xdmp.jsonValidate(jsonRecord, '/schemas/NewSchema.json');

并确保将架构文档插入到架构数据库中,而不是内容数据库中。

【讨论】:

  • 啊,我明白了,谢谢!
猜你喜欢
  • 2014-06-16
  • 2013-05-29
  • 1970-01-01
  • 1970-01-01
  • 2018-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-25
相关资源
最近更新 更多