com.jayway.jsonpath.DocumentContext to org.json.JSONObject?

Viewed 1006

I want to both validate JSON and then use json-path for JPath queries. The validation is using json-schema which wants a JSONObject of the JSON to validate it. json-path wants a String or InputStream (code is in Java).

In a perfect world both could work off the same object as it's read in. However json-schema is built around the JSONObject and changing that would be a major re-write. And so, the next best is parse using json-path and then from the DocumentContext get a JSONObject of it.

Is there a way to do this? If not, then is the best way to read in the JSON as a JSONObject, feed that to the schema validation, and then get the String representation of that to pass to json-path?

0 Answers
Related