Closed ryandietrich closed 2 years ago
So you're passing the ByteArrayInputStream into a schema constructor?
Or is it the object to test that you're passing in that way? If that's the case and the object is a string of JSON, you'll have to parse it first using a parser library. For example using the org.json library it's
new JSONObject(jsonString).toMap()
I was passing it in as a byteArrayInputStream. I was just confused how the library seemed to assume all schemas came from files and it didn't have a simple "string" based approach.
I will add a new method to validate a string containing JSON data. Since there's a parser embedded already (for fetching schemas from http) it's not difficult to do. I can't change the behavior of the existing parse method as validating a string (not necessarily containing JSON data) by a schema is a valid thing to do.
Added the new methods, see https://github.com/jimblackler/jsonschemafriend#basic-example-using-json-strings
I can load a schema from a file just fine, either as a resource, or directly using a java.io.file. When I try to take a string, and transform it into a ByteArrayInputStream, I get this rather cryptic error.
I checked out the code, walked through SchemaStore, added some logging, re-compiled, and re-ran and I don't see a clear path on how to fix my issue.
My use case is pretty simple. I have a string that contains a schema, and a string that contains JSON data that I want to validate with the schema mentioned earlier. I can't figure out how to do this with this library, so I am moving on to something else.