[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avro-user
Subject:    Re: Validating a JSON schema
From:       Doug Cutting <cutting () apache ! org>
Date:       2011-03-25 17:52:28
Message-ID: 4D8CD65C.3050302 () apache ! org
[Download RAW message or body]

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?

Doug

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic