Skip to main content

juneau-marshall-rdf

Maven
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-marshall-rdf</artifactId>
<version>${juneau.version}</version>
</dependency>
Jarjuneau-marshall-rdf-10.0.0.jar
OSGiorg.apache.juneau.marshall-rdf_10.0.0.jar
LinksMaven Central · Javadocs · Source

Contents/Features​

The juneau-marshall-rdf library provides additional serializers and parsers for RDF. These rely on the Apache Jena library to provide support for the following formats:

Text-based formats:

  • RDF/XML
  • RDF/XML-Abbrev
  • RDF/JSON
  • N-Triples (W3C)
  • Turtle (W3C)
  • N3 (Notation3)
  • N-Quads
  • TriG (Turtle with named graphs)
  • TriX (XML-based)
  • JSON-LD (W3C)

Binary formats:

  • RDF/THRIFT (Apache Thrift encoding)
  • RDF/PROTO (Protocol Buffers encoding)

See RDF Basics for full documentation.

When to use it​

Add this module when you need to read or write RDF through the same Person.class style API as the other marshallers, without calling Jena directly.

Example​

import org.apache.juneau.marshall.jena.marshaller.*;

public class RdfExample {

public static class Person {
public String name;
public int age;
public Person() {}
public Person(String name, int age) { this.name = name; this.age = age; }
}

public static void main(String[] args) throws Exception {
Person person = new Person("Alice", 30);
String turtle = Turtle.of(person);
Person restored = Turtle.to(turtle, Person.class);
System.out.println(restored.name + " " + restored.age);
}
}

Options​

FormatMarshaller
RDF/XMLRdfXml
TurtleTurtle
N-TriplesNTriple
JSON-LDJsonLd
RDF/THRIFTRdfThrift
RDF/PROTORdfProto

See also​

In This Section​