Class RdfJsonParser

All Implemented Interfaces:
RdfMetaProvider, XmlMetaProvider

public class RdfJsonParser extends RdfParser
Subclass of RdfParser for parsing RDF/JSON into POJOs.

Accepts RDF in JSON notation and converts it to Java beans, maps, collections, and primitive types. Date/time literals are parsed via ISO 8601.

Examples:

// Parse RDF/JSON string into a bean. String rdfJson = ...; // RDF/JSON content Person person = RdfJsonParser.DEFAULT.read(rdfJson, Person.class);

// Or use the RdfJson marshaller for convenience. Person person = RdfJson.to(rdfJson, Person.class);

// Parse into a list of beans. List<Person> people = RdfJsonParser.DEFAULT.read(rdfJson, List.class, Person.class);

// Custom parser with swaps. RdfJsonParser p = RdfJsonParser.create().swaps(DateSwap.class).build(); MyBean bean = p.read(rdfJson, MyBean.class);

Example input (bean with name/age):

{ "<subject>": { "<.../name>": [{ "value": "Alice" }], "<.../age>": [{ "value": 30, "type": "literal" }] } }

Complex (nested address + array):

{ "<...>": { "<.../name>": [{ "value": "Alice" }], "<.../address>": [{ "type": "uri", "value": ".../address" }] }, "<.../address>": { "<.../street>": [{ "value": "123 Main St" }], "<.../city>": [{ "value": "Boston" }], "<.../state>": [{ "value": "MA" }] } }

Notes:
  • This class is thread safe and reusable.
See Also:
  • Field Details

    • DEFAULT

      public static final RdfJsonParser DEFAULT
      Default RDF/JSON parser, all default settings.
  • Constructor Details

  • Method Details

    • create

      public static RdfParser.Builder<?> create()
      Creates a new builder for this object.
      Returns:
      A new builder.