Creating a Schema instance from a string #212
Unanswered
ballcoach12
asked this question in
Q&A
Replies: 1 comment
-
you have to do json unmarshal the json string, to add as resource. doc, err := jsonschema.UnMarshalJSON(strings.NewReader(`{
"type": "object",
"properties": {
"a": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
}
}`)
if err!=nil {
panic(err)
}
c := jsonschema.NewCompiler()
if err := c.AddResource("schema.json", doc); err!=nil {
panic(err)
}
sch, err := c.Compile("schema.json") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the following string that defines a simple schema:
When I validate the following JSON:
I get the following error:
invalid jsonType []uint8
I'm not an expert with JsonSchema, but I don't see anything invalid here. And online validators show this to be passing. Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions