Search code examples
owlowl-api

OWLClass representation in JSON format


I know it is possible to save the whole ontology in JSON, would it be possible to convert single OWLClass to JSON? Something like:

OWLClass cl = ...;
JSONObject obj = cl.toJSON();
Thanks!

Solution

  • There's no ready method to do that in OWLAPI, however an OWLClass consists of just an IRI, whose only data is a string. So it is pretty simple to serialize a single object as a string plus a type specification, and deserialize accordingly.

    An introduction to custom serialization for JSON is available here