JsonLdSerializer
in package
implements
SerializerInterface
Thin wrapper providing RdfInterface\Serializer API for JSON-LD the parser provided by the ml/json-ld library.
Be aware the implementation provided by the ml/json-ld library is not really focused on performance. If you value speed and/or low memory footprint consider using other serialization format.
Tags
Interfaces, Classes, Traits and Enums
Table of Contents
- TRANSFORM_COMPACT = 3
- TRANSFORM_EXPAND = 1
- TRANSFORM_FLATTEN = 2
- TRANSFORM_NONE = 0
- $baseUri : string|null
- $context : mixed
- $jsonEncodeFlags : int
- $options : array<string, mixed>
- $transform : int
- __construct() : mixed
- serialize() : string
- serializeStream() : void
Constants
TRANSFORM_COMPACT
public
mixed
TRANSFORM_COMPACT
= 3
Tags
TRANSFORM_EXPAND
public
mixed
TRANSFORM_EXPAND
= 1
Tags
TRANSFORM_FLATTEN
public
mixed
TRANSFORM_FLATTEN
= 2
Tags
TRANSFORM_NONE
public
mixed
TRANSFORM_NONE
= 0
Tags
Properties
$baseUri
private
string|null
$baseUri
Tags
$context
private
mixed
$context
Tags
$jsonEncodeFlags
private
int
$jsonEncodeFlags
Tags
$options
private
array<string, mixed>
$options
Tags
$transform
private
int
$transform
Tags
Methods
__construct()
public
__construct([string $baseUri = null ][, int $transform = self::TRANSFORM_NONE ][, int $jsonEncodeFlags = JSON_UNESCAPED_SLASHES ][, mixed $context = null ][, array<string, mixed> $options = [] ]) : mixed
Parameters
- $baseUri : string = null
- $transform : int = self::TRANSFORM_NONE
-
transformation to be applied before serializing to string. One of
JsonLdSerializer::TRANSFORM_NONE
(default),JsonLdSerializer::TRANSFORM_EXPAND
,JsonLdSerializer::TRANSFORM_FLATTEN
orJsonLdSerializer::TRANSFORM_COMPACT
. In case ofJsonLdSerializer::TRANSFORM_COMPACT
the$context
parameter has to be provided. - $jsonEncodeFlags : int = JSON_UNESCAPED_SLASHES
-
flags to be passed to the
json_encode()
call serializing output to a string - see https://www.php.net/manual/en/function.json-encode.php . - $context : mixed = null
-
context to be passed to
ML\JsonLD\JsonLD::compact()
orML\JsonLD\JsonLD::flatten()
when$transform
equalsJsonLdSerializer::TRANSFORM_COMPACT
orJsonLdSerializer::TRANSFORM_FLATTEN
, repectively. - $options : array<string, mixed> = []
-
options to be passed to the corresponding
ML\JsonLD\JsonLD
method (expand()
,compact()
orflatten()
according to the$transform
parameter value). If you would like these methods to be better documented, then you are not then only one... :-(
Tags
Return values
mixed —serialize()
public
serialize(QuadIteratorInterface|QuadIteratorAggregateInterface $graph[, RdfNamespaceInterface|null $nmsp = null ]) : string
Parameters
- $graph : QuadIteratorInterface|QuadIteratorAggregateInterface
- $nmsp : RdfNamespaceInterface|null = null
-
If passed, it's used for compacting the output. Unfortunately only property URIs can be compacted that way (of course for that full property URIs must be registered as "namespaces").
Tags
Return values
string —serializeStream()
public
serializeStream(mixed $output, QuadIteratorInterface|QuadIteratorAggregateInterface $graph[, RdfNamespaceInterface|null $nmsp = null ]) : void
Parameters
- $output : mixed
- $graph : QuadIteratorInterface|QuadIteratorAggregateInterface
- $nmsp : RdfNamespaceInterface|null = null
-
unused but required for compatibility with the
\rdfInterface\Serializer
.