Re: [erlang-questions] Jesse - a JSON schema validator in Erlang

18 views
Skip to first unread message

Motiejus Jakštys

unread,
Feb 20, 2013, 1:30:20 PM2/20/13
to Igor Karymov, erlang-pr...@googlegroups.com, Erlang, pi...@googlegroups.com
On Wed, Feb 20, 2013 at 4:18 PM, Igor Karymov <ingh...@gmail.com> wrote:
> Another approach of scheme definition that can work with json:
> https://github.com/alavrik/piqi

Piqi is cool, but if you have external clients, then .xsd, .proto and
json-scheme (in descending popularity) are the ways to go. .piqi
format for objective-c programmer to communicate json.. what? So not a
really good use case.

I once used piqi for protobuffer-only communication. Wrote my piqi
files, asked piqi to convert them to .proto, and gave these to the
third party. Just because I found to writing .piqi than protobuffers
easier.

In the end, I would love a piqi-to-xsd and piqi-to-json-schema
converters. That would allow to use piqi in corporate environments
(a.k.a. where xml and xsd are mandatory), and with more flexible
clients that use json, which you could pass the JSON schema, requiring
much less manual documentation.

Though I realize that Anton has much more interesting and useful
things to do than writing piqi-any converters (piqic erlang!), this
would be a nice addition that would enable piqi usage in some
environments. Hell, shouldn't be too hard to implement. Maybe I will
do that myself some day.

Igor, you raised a valid point. But it's not there.. Yet. :)

--
Motiejus Jakštys

Anton Lavrik

unread,
Feb 21, 2013, 1:18:13 AM2/21/13
to pi...@googlegroups.com, Igor Karymov, Erlang
On Wed, Feb 20, 2013 at 12:30 PM, Motiejus Jakštys
<desir...@gmail.com> wrote:
> On Wed, Feb 20, 2013 at 4:18 PM, Igor Karymov <ingh...@gmail.com> wrote:
>> Another approach of scheme definition that can work with json:
>> https://github.com/alavrik/piqi

Piqi does support working from JSON from Erlang and does it really
well. For example, when it finds a problem, it returns a description
of it and points to the exact line:column location in the input.

Because it is more of a data serialization system, Piqi doesn't
support a jesse-like interface for validating JSON dynamically, but it
can be added. If anybody is interested, please let me know.

> In the end, I would love a piqi-to-xsd and piqi-to-json-schema
> converters. That would allow to use piqi in corporate environments
> (a.k.a. where xml and xsd are mandatory), and with more flexible
> clients that use json, which you could pass the JSON schema, requiring
> much less manual documentation.

piqi to X conversion can be done fairly easily. First, Piqi
specification is stable, small and extensible. Essentially, it has a
reasonably small but very powerful set of types that can be mapped to
pretty much anything. Second, nobody needs to parse .piqi Just run
"piqi compile -t json|pb|xml <.piqi>" and read JSON, XML or Protocol
Buffers output using any language. (The "piqi" command is a standalone
statically linked program).

Anton
Reply all
Reply to author
Forward
0 new messages