avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Validating a JSON schema
Date Fri, 25 Mar 2011 17:52:28 GMT
On 03/25/2011 10:34 AM, Aurora Skarra-Gallagher wrote:
> I would like to be able to validate the schema. Is there a way for me to
> take my schema and also a JSON output string from my API and validate
> that the output matches the schema?

I don't know of an explicit command-line validator, but you might use
some of the other command line tools for this purpose.

For example, the 'jsontofrag' tool takes a schema and a JSON-encoded
datum and generates a binary-encoded datum.  And the 'fragtojson' takes
a binary-encoded datum and a schema and produces a JSON-encoded datum.
You could pipe these together and check that the output looks like the
input, e.g.:

echo 2 | java -jar avro-tools.jar jsontofrag '"int"' - | java -jar
avro-tools.jar fragtojson '"int"' -

Does that help?


View raw message