David M. Karr
David M. Karr

Reputation: 15235

How to do json schema validation in Eclipse

I'm trying to set up basic json schema validation in Eclipse. From what I understand, Eclipse supports this, but I can't find any information about how to actually take advantage of this.

I tried putting a valid schema def (from http://json-schema.org/example1.html) in "example.schema.json" and then a syntactically valid but schema-invalid "example.json" in the same directory, and then selecting "Validate" from the context menu, but that didn't appear to do anything.

What am I missing?

Upvotes: 1

Views: 5180

Answers (1)

Wolfgang Hübner
Wolfgang Hübner

Reputation: 31

You need to add the JSON Schema to the JSON Catalog for each JSON file you want to validate. Example: To validate "faces.json" with "facesSchema.json":

Window -> Preferences -> JSON -> JSON Catalog

Add a new Entry with and enter the follwing into the dialog:

"File Match": "faces.json" and "URL": "file://../facesSchema.json"

Screenshot: Eclipse Settings for JSON Catalog

(I'm using Eclipse Photon)

Upvotes: 3

Related Questions