4

Is there way to do schema validation on JSON documents, just like the xsd schema validation for XML documents in MarkLogic 8?

Thanks

gjwilson21
  • 123
  • 6

1 Answers1

4

There is no native JSON schema validation in MarkLogic 8, but xdmp.jsonNodeValidate() is available in MarkLogic 9.

Having said that, there are many JS JSON validation libraries. Therefore, it is not unrealistic to think that you could use a validation library in JavaScript for this task.

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • For what it's worth, I've done some encouraging experiments with jsen (https://www.npmjs.com/package/jsen), which generates a validation function for a schema. To validate JSON on the server, you execute the validation function in the server-side JavaScript engine. – ehennum Nov 19 '15 at 16:22
  • Ooh. Do tell more, @ehennum. – Justin Makeig Nov 20 '15 at 17:20
  • Ummm. Well. That's really all there is to it. 1. Write the JSON schema. 2. Generate the JavaScript validation function. 3. Any time you want to validate a document against that JSON schema, pass the document to the generated JavaScript validation function. At the time, jsen was compared well on both completeness and performance, but there's a lot of activity in JSON schema validators. – ehennum Nov 25 '15 at 16:31