6

Using ajv v8.6.3 nodejs and typescript

Trying to parse JSON however I am getting this Error: strict mode: unknown keyword: "$schema"

anyone shed some light on this?

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)
succeed
  • 834
  • 1
  • 11
  • 28
  • You are importing the draft7MetaSchema as instructed in JSON Schema draft-2019-09 section of the [docs](https://ajv.js.org/json-schema.html#draft-2019-09)? Mind sharing your whole file? – rsmets Dec 29 '22 at 19:18
  • ~Also, when I import the AJV module v8.6.3 I do not get the compileParser function. Strange... considering that method is mentioned in the v8 [docs](https://ajv.js.org/api.html#ajv-compileparser-schema-object-json-string-any)~ EDIT: found the missing link in the docs. Need to import AJV with the JDT dist. The getting started [section](https://github.com/ajv-validator/ajv/blob/d6d8d5f197d793a739378e5e3567151dcd0fbb61/docs/guide/getting-started.md#parsing-and-serializing-json-) of readme was the only place I saw this mentioned. Again, would be super helpful to see your whole file. Thanks. – rsmets Dec 29 '22 at 19:21

0 Answers0