Java Binding for JSON-LD - Jackson (JB4JSON-LD-Jackson) is a binding of JB4JSON-LD for Jackson.
The core implementation of JB4JSON-LD with a mapping example can be found at https://github.com/kbss-cvut/jb4jsonld. The repository also contains Wiki with some basic documentation.
JB4JSON-LD is based on annotations from JOPA, which enable POJO attributes to be mapped to ontological constructs (i.e. to object, data or annotation properties) and Java classes to ontological classes.
Use @OWLDataProperty
to annotate data fields and @OWLObjectProperty
to annotate fields referencing other mapped entities.
To integrate the library with Jackson, register a cz.cvut.kbss.jsonld.jackson.JsonLdModule
in Jackson's ObjectMapper
like this:
objectMapper.registerModule(new JsonLdModule());
and you should be good to go. See the example application in example for a minimalist demo of using JB4JSON-LD Jackson.
https://github.com/kbss-cvut/jopa-examples/tree/master/jsonld provides a more realistic example of JB4JSON-LD-Jackson in action. TermIt is then a real-world information system using JB4JSON-LD.
The serializer's output has been verified to be a valid JSON-LD and is parseable by Java's JSON-LD reference implementation jsonld-java.
The output is by default a context-less compacted JSON-LD, which uses full IRIs for attribute names.
Since version 0.10.0, it is possible to configure JB4JSON-LD to output compacted JSON-LD with context (@context
).
This allows better compatibility with legacy applications not supporting JSON-LD. To enable context-based serialization,
configure the JsonLdModule
as follows:
JsonLdModule module = new JsonLdModule();
module.configure(SerializationConstants.FORM, SerializationConstants.FORM_COMPACT_WITH_CONTEXT);
Since we are using jsonld-java to first process the incoming JSON-LD, it does not matter in which form (expanded, framed, flattened) the input is.
There are two ways to get JB4JSON-LD-Jackson:
- Clone repository/download zip and build it with Maven,
- Use a Maven dependency:
<dependency>
<groupId>cz.cvut.kbss.jsonld</groupId>
<artifactId>jb4jsonld-jackson</artifactId>
</dependency>
LGPLv3