Open jpblair opened 9 years ago
:+1: I would also like this. Haven't found it anywhere in the API so far.
I would love this as well.
@fge are you willing to accept a PR for this?
@febpetroni @rodrigosaito I was able to find a solution for this after doing some digging around. Each ProcessingMessage
in the ProcessingReport
has an asJson()
method which returns a JsonNode
object. I was able to create a JSON array and iterate through each ProcessingMessage
, adding its asJson()
output to the array. Hope this helps.
Another way to do this is to use the ListProcessingReport
.
ProcessingReport report = schema.validate(jsonInput, true);
ListProcessingReport listProcessingReport = new ListProcessingReport();
listProcessingReport.mergeWith(report);
System.out.println(listProcessingReport.asJson());
ListProcessingReport
has a copy constructor that would cut that code down by a line but it wasn't working for me.
I'm planning to use the library to validate data coming in from clients, and on error return the detailed error information. Is there any way to get this in a more JSON-friendly format? For example, having level/schema/instance/etc all be separate JSON fields. Apologies if this already exists and I just haven't found it.