Transform ontology to json schema?

684 views
Skip to first unread message

Kai Liu

unread,
Apr 7, 2022, 2:21:00 PM4/7/22
to TopBraid Suite Users
Hi,

we have a set of json files (not json-ld) that should be validated with an ontology developed in EDG. The json objects should contain the properties defined in the ontology classes, and the defined rules of these properties should be obeyed. 

What is the best way to do that? We are thinking of writing a converter that can convert the ontology into a json schema for the validation. But I am not sure whether this will work for all cases. Another idea would be to create RDF files from these json files for the validation. Any experience or ideas would be much appreciated. Thanks.

Best regards, Kai

Holger Knublauch

unread,
Apr 7, 2022, 6:37:51 PM4/7/22
to topbrai...@googlegroups.com


On 2022-04-08 4:20 am, Kai Liu wrote:
Hi,

we have a set of json files (not json-ld) that should be validated with an ontology developed in EDG. The json objects should contain the properties defined in the ontology classes, and the defined rules of these properties should be obeyed. 

What is the best way to do that? We are thinking of writing a converter that can convert the ontology into a json schema for the validation.
In principle a SHACL to JSON Schema converter would be useful and should be created at some stage. It would, of course, need to make some assumptions about how RDF instance data gets mapped to JSON objects.

But I am not sure whether this will work for all cases.
My understanding is that JSON Schema is less expressive than SHACL, so it would only work for the very simple constraint types such as sh:minCount, sh:datatype and sh:class.

Another idea would be to create RDF files from these json files for the validation. Any experience or ideas would be much appreciated. Thanks.

Converting JSON into RDF is relatively easy to implement using ADS scripts. ADS would also be able to pull multiple JSON files from web services etc, if that's needed. And once in RDF you could validate the merged data from multiple JSON files, in case there are constraints that span the semantics of individual files. And such constraints can look up data from other (knowledge) graphs, e.g. with reference data. All this would be very hard to do in JSON Schema. So if you already have your semantics expressed in the ontology, I guess writing a converter to RDF instances sounds best.

If you need further help with the conversion, it would be helpful to see the sample JSON files and the target ontology. There are many strategies to define mappings, e.g. through annotations in the classes/property shapes that instruct a generic converter, but it all depends on what your requirements are.

Holger



Best regards, Kai

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/fffc83ad-aad1-43f2-9e10-69fc7abcbb66n%40googlegroups.com.

Rob Atkinson

unread,
Apr 7, 2022, 11:35:03 PM4/7/22
to topbrai...@googlegroups.com
FWIW this is an area of research I am embarking on in my role with the Open Geospatial Consortium - specifically looking at support for modularised data models via OGC APIs - currently defined around JSON schema, but I am hoping to find workable patterns and tooling to support an uplift to JSON-LD.

The way I see it modular OWL models -> modular JSON-LD context document accessible via content-negotiation from the same location as the OWL model. 

SHACL-shapes -> JSON schema using these JSON-LD contexts

 (Proxy OWL models can be used to wrap models that dont offer canonical JSON-LD contexts)

the trick as always will be to handle the "hand-rolled" JSON component models people might want to enforce - such as GeoJSON  when rolling out a schema for a model that uses the underlying models.

Uplift of GeoSPARQL to support these patterns is on the cards.

please contact me at ratkinson -at- ogc.org if you have a deeper interest in a scalable architecture for these capabilities and/or the role of standards organisations in supporting enabling components.

Reply all
Reply to author
Forward
0 new messages