CycloneDX Library

JsonSerializer extends BaseSerializer
in package

Transform data models to JSON.

Tags
psalm-type

TNormalizedBom = array<string, mixed>

template-extends
author

jkowalleck

Table of Contents

Constants

JsonEncodeFlagsAllowedOptions  = 0 | \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_APOS | \JSON_HEX_QUOT | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE
List of allowed options for {@see jsonEncodeFlags}.
JsonEncodeFlagsDefaultOptions  = 0 | \JSON_UNESCAPED_SLASHES
List of mandatory options for $jsonEncodeFlags.
JsonEncodeFlagsDefaults  = 0 | \JSON_THROW_ON_ERROR | \JSON_PRESERVE_ZERO_FRACTION
Defaults of {@see $jsonEncodeFlags}.

Properties

$jsonEncodeFlags  : int
Flags for {@see \json_encode()}.
$normalizerFactory  : NormalizerFactory

Methods

__construct()  : mixed
serialize()  : string
Serialize a {@see Bom} to string.
realNormalize()  : TNormalizedBom
Normalize a {@see Bom} to the data structure that {@see realSerialize()} can handle.
realSerialize()  : string
Serialize a {@see realNormalize() normalized} version of a {@see Bom}.

Constants

JsonEncodeFlagsAllowedOptions

List of allowed options for {@see jsonEncodeFlags}.

private int JsonEncodeFlagsAllowedOptions = 0 | \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_APOS | \JSON_HEX_QUOT | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE

Bit mask consisting of JSON_*.

Some JSON flags could break the output, so they are not whitelisted.

Tags
see
https://www.php.net/manual/en/json.constants.php

JsonEncodeFlagsDefaults

Defaults of {@see $jsonEncodeFlags}.

private int JsonEncodeFlagsDefaults = 0 | \JSON_THROW_ON_ERROR | \JSON_PRESERVE_ZERO_FRACTION

Bit mask consisting of JSON_*.

These defaults are required to have valid output in the end.

Tags
see
https://www.php.net/manual/en/json.constants.php

Properties

Methods

__construct()

public __construct(NormalizerFactory $normalizerFactory[, int $jsonEncodeFlags = self::JsonEncodeFlagsDefaultOptions ]) : mixed
Parameters
$normalizerFactory : NormalizerFactory
$jsonEncodeFlags : int = self::JsonEncodeFlagsDefaultOptions

Bitmask consisting of JSON_*. see JsonEncodeFlagsAllowedOptions

serialize()

Serialize a {@see Bom} to string.

public final serialize(Bom $bom[, bool|null $prettyPrint = null ]) : string
Parameters
$bom : Bom

the BOM to serialize

$prettyPrint : bool|null = null

whether to beatify the resulting string. A null value means no preference.

Attributes
#[Override]
Return values
string

realNormalize()

Normalize a {@see Bom} to the data structure that {@see realSerialize()} can handle.

protected realNormalize(Bom $bom) : TNormalizedBom
Parameters
$bom : Bom
Attributes
#[Override]
Return values
TNormalizedBom

a version of the Bom that was normalized for serialization

realSerialize()

Serialize a {@see realNormalize() normalized} version of a {@see Bom}.

protected realSerialize(mixed $normalizedBom, bool|null $prettyPrint) : string
Parameters
$normalizedBom : mixed

a version of the Bom that was normalized for serialization

$prettyPrint : bool|null
Attributes
#[Override]
Return values
string

        
On this page

Search results