Hi all mates,

while working on an idea of a JSON streaming parser for the Feature model,
I noticed that the parser has the delegation of validating the input, other
than transforming the json structure the the Feature model.

Given my experience of (many, sigh) years ago I when contributed to the
Plexus Modello the JSON schema generator, I wrote an initial prototype of
the Apache Sling Feature JSON schema[2] compliant with the latest #7 draft,
and playing around with tests model with an online schema validator[2].
The proposed schema supports extensions handling, validating the object
value type (JSON/TEXT/ARTIFACTS).

I see the advantages below of adopting such schema:

 * to have a formal and standard way to describe the Feature data structure
in JSON model;

 * provide an easy way to assist users on editing Feature json files in the
right way inside IDEs, as shown in Eclipse[3] and IntelliJ[4];

 * separate the input validation - it can be delegated by the Feature
Analyzer - and the parser phases (which should just take care of
transforming the JSON data to the Feature model): unfortunately there are
no up-to-date Java implementations, the most well-known [5] works on
org.json implementation and the other one [6] is "still" at the draft #4
(aside that relies on too many dependencies).
An alternative could be writing a simple validator for our use case, based
on the proposed schema.

WDYT?
I would like to contribute the schema [1] to one of the feature modules,
maybe the -io is the more appropriate.

I hope that could be interesting, have a nice day and all the best!
~Simo

[1] https://gist.github.com/simonetripodi/c69d2ffebdbd2c4b1355df60568f1ab5
[2] https://www.jsonschemavalidator.net/
[3]
https://stackoverflow.com/questions/50011837/how-to-do-json-schema-validation-in-eclipse
[4] https://www.jetbrains.com/help/idea/settings-languages-json-schema.html
[5] https://github.com/everit-org/json-schema
[6] https://github.com/java-json-tools/json-schema-validator

http://people.apache.org/~simonetripodi/
http://twitter.com/simonetripodi

Reply via email to