首页 > 解决方案 > Ajv:错误:严格模式:未知关键字:“$schema”

问题描述

使用 ajv v8.6.3 nodejs 和 typescript

试图解析 JSON 但是我得到了这个Error: strict mode: unknown keyword: "$schema"

有人对此有所了解吗?

export const mySchema ={
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
        "names": {
            "items": {
                "type": "number"
            },
            "type": "array"
        }
    },
    "type": "object"
}


const ajv = new Ajv()

ajv.addMetaSchema(draft7MetaSchema)

ajv.compileParser(mySchema)

标签: node.jsjsonjson-schema-validatorajv

解决方案


推荐阅读