leadpony / justify

Justify is a JSON validator based on JSON Schema Specification and Jakarta JSON Processing API (JSON-P).
Apache License 2.0
96 stars 18 forks source link

Validating both JSON and YAML in single project #64

Closed marceloverdijk closed 3 years ago

marceloverdijk commented 3 years ago

I have a project which is validating both JSON and YAML documents so I included justify, joy-classic and joy-yaml as dependencies.

I can successfully validate my JSON documents but validating the YAML document fails right away:

[line=1,column=1,offset=0] Unexpected char 'd' was found.

The document starts with:

developers:
  - foo

I copied the code from here which is identical to the JSON validation code. How does Justify determine to use JSON or YAML as I have the feeling it's not treating my YAML document as YAML.

Is it maybe because I have both joy-classic and joy-yaml on the classpath?

marceloverdijk commented 3 years ago

JsonValidationService.newInstance(new YamlProvider()) does the trick; closing this one.