java.lang.Object
org.apache.jena.riot.writer.WriterDatasetRIOTBase
org.apache.jena.riot.writer.JsonLD10Writer
- All Implemented Interfaces:
WriterDatasetRIOT
Deprecated.
Migrate to JSON-LD 1.1
Writer that prints out JSON-LD.
By default, the output is "compact" (in JSON-LD terminology), and the JSON is "pretty" (using line breaks).
One can choose another form using one of the dedicated RDFFormats (JSONLD_EXPAND_PRETTY, etc.).
For formats using a context (that is, which have an "@context" node), (compact and expand),
this automatically generates a default one.
One can pass a jsonld context using the (jena) Context mechanism, defining a (jena) Context
(sorry for this clash of "contexts"), (cf. last argument in
WriterDatasetRIOT.write(OutputStream out, DatasetGraph datasetGraph, PrefixMap prefixMap, String baseURI, Context context)
)
with:
Context jenaContext = new Context() jenaCtx.set(JsonLDWriter.JSONLD_CONTEXT, contextAsJsonString);where contextAsJsonString is a JSON string containing the value of the "@context". It is possible to change the content of the "@context" node in the output using the
JSONLD_CONTEXT_SUBSTITUTION
Symbol.
For a frame output, one must pass a frame in the jenaContext using the JSONLD_FRAME
Symbol.
It is also possible to define the different options supported
by JSONLD-java using the JSONLD_OPTIONS
Symbol
The JsonLDWriteContext
is a convenience class that extends Context and
provides methods to set the values of these different Symbols that are used in controlling the writing of JSON-LD.
Note that this class also provides a static method to convert jena RDF data to the corresponding object in JsonLD API:
toJsonLDJavaAPI(org.apache.jena.riot.RDFFormat.JSONLDVariant, DatasetGraph, PrefixMap, String, Context)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Symbol
Deprecated.if creating a (jsonld) context from dataset, should we include all the prefixes defined in graph's prefix mappings value: a Boolean (default: true)static final Symbol
Deprecated.Expected value: the value of the "@context" (a JSON String, or the object expected by the JSONLD-java API)static final Symbol
Deprecated.Expected value: the value of the "@context" to be put in final output (a JSON String) This is NOT the context used to produce the output (given by JSONLD_CONTEXT, or computed from the input RDF.static final Symbol
Deprecated.value: a JSON String, or the frame object expected by JsonLdProcessor.framestatic final Symbol
Deprecated.value: the option object expected by JsonLdProcessor (instance of JsonLdOptions) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLang()
Deprecated.static Object
toJsonLDJavaAPI
(RDFFormat.JSONLDVariant variant, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context jenaContext) Deprecated.the JsonLD-java API object corresponding to a dataset and a JsonLD format.void
write
(OutputStream out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context) Deprecated.void
Deprecated.Use of Writer is discouraged - let the serializer manage character sets in accordance with the format
-
Field Details
-
JSONLD_CONTEXT
Deprecated.Expected value: the value of the "@context" (a JSON String, or the object expected by the JSONLD-java API) -
JSONLD_CONTEXT_SUBSTITUTION
Deprecated.Expected value: the value of the "@context" to be put in final output (a JSON String) This is NOT the context used to produce the output (given by JSONLD_CONTEXT, or computed from the input RDF. It is something that will replace the @context content. This is useful- for the cases you want to have a URI as value of @context, without having JSON-LD java to download it and
- as a trick to change the URIs in your result.
-
JSONLD_FRAME
Deprecated.value: a JSON String, or the frame object expected by JsonLdProcessor.frame -
JSONLD_OPTIONS
Deprecated.value: the option object expected by JsonLdProcessor (instance of JsonLdOptions) -
JSONLD_ADD_ALL_PREFIXES_TO_CONTEXT
Deprecated.if creating a (jsonld) context from dataset, should we include all the prefixes defined in graph's prefix mappings value: a Boolean (default: true)
-
-
Constructor Details
-
JsonLD10Writer
Deprecated.
-
-
Method Details
-
getLang
Deprecated. -
write
public void write(Writer out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context) Deprecated.Description copied from interface:WriterDatasetRIOT
Use of Writer is discouraged - let the serializer manage character sets in accordance with the format- Specified by:
write
in interfaceWriterDatasetRIOT
- Specified by:
write
in classWriterDatasetRIOTBase
- Parameters:
out
- Writerdataset
- DatasetGraph to be writtenprefixMap
- PrefixMap - maybe null (default should be to use the prefix mapping from the Graph)baseURI
- base URI - may be null for "none"context
- Context (see specific implementation for details)
-
write
public void write(OutputStream out, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context context) Deprecated.- Specified by:
write
in interfaceWriterDatasetRIOT
- Specified by:
write
in classWriterDatasetRIOTBase
- Parameters:
out
- OutputStreamdataset
- DatasetGraph to be writtenprefixMap
- PrefixMap - maybe null (default should be to use the prefix mapping from the Graph)baseURI
- base URI - may be null for "none"context
- Context (see specific implementation for details)
-
toJsonLDJavaAPI
public static Object toJsonLDJavaAPI(RDFFormat.JSONLDVariant variant, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context jenaContext) throws com.github.jsonldjava.core.JsonLdError, com.fasterxml.jackson.core.JsonParseException, IOException Deprecated.the JsonLD-java API object corresponding to a dataset and a JsonLD format.- Throws:
com.github.jsonldjava.core.JsonLdError
com.fasterxml.jackson.core.JsonParseException
IOException
-