JsonLdGraphEncoderOptions class

Configuration options for JSON-LD encoding

This class provides configuration options for customizing the behavior of the JSON-LD encoder. It extends the base RDF encoder options to add JSON-LD specific functionality.

Currently, the main customization is the ability to provide custom prefixes for the JSON-LD context, allowing for more readable and application-specific compact IRIs in the output.

Potential future options might include:

  • Control over formatting (compact vs. expanded form)
  • Custom handling of complex datatypes
  • Options for including/excluding @context
  • Named graph serialization settings

Example usage:

final options = JsonLdEncoderOptions(
  customPrefixes: {
    'ex': 'http://example.org/',
    'app': 'http://myapp.com/terms#'
  }
);

final encoder = JsonLdEncoder(options: options);

Constructors

JsonLdGraphEncoderOptions({JsonLdOutputMode outputMode = JsonLdOutputMode.compact, Map<String, String> customPrefixes = const {}, IriRelativizationOptions iriRelativization = const IriRelativizationOptions.full(), bool generateMissingPrefixes = true, bool includeBaseDeclaration = true, bool? useNativeTypes, bool useRdfType = false, RdfDirection? rdfDirection, Object? compactionContext})
Creates a new JSON-LD encoder options object
const

Properties

compactionContext Object?
Optional compaction context for JsonLdOutputMode.compact and JsonLdOutputMode.flattened.
final
customPrefixes Map<String, String>
Custom namespace prefixes to use during encoding.
finalinherited
generateMissingPrefixes bool
Controls automatic generation of namespace prefixes for IRIs without matching prefixes.
final
hashCode int
The hash code for this object.
no setterinherited
includeBaseDeclaration bool
Whether to include base URI declarations in the output.
final
iriRelativization → IriRelativizationOptions
Options for controlling IRI relativization behavior.
finalinherited
outputMode JsonLdOutputMode
The output mode for JSON-LD encoding.
final
rdfDirection RdfDirection?
Controls how RDF text direction is represented in the output.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useNativeTypes bool?
Whether to convert xsd:boolean, xsd:integer and xsd:double literals to native JSON values instead of the expanded {"@value":"…","@type":"…"} form.
final
useRdfType bool
When true, rdf:type triples are rendered as ordinary predicates instead of being converted to @type.
final

Methods

copyWith({JsonLdOutputMode? outputMode, Map<String, String>? customPrefixes, bool? generateMissingPrefixes, bool? includeBaseDeclaration, IriRelativizationOptions? iriRelativization, bool? useNativeTypes, bool? useRdfType, RdfDirection? rdfDirection, Object? compactionContext}) JsonLdGraphEncoderOptions
Creates a copy of this options instance with the specified overrides.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

from(RdfGraphEncoderOptions options) JsonLdGraphEncoderOptions
Creates a JSON-LD encoder options object from generic RDF encoder options