final class JsonTest
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A test of whether a value is JSON of a kind: a IS [NOT] JSON [VALUE|ARRAY|OBJECT|SCALAR] [WITH|WITHOUT UNIQUE KEYS].

Mirrors PostgreSQL's JsonIsPredicate node.

Rule: PG-JSON-TEST-001. Facts: boolean for an operand of type text, json, jsonb or bytea (a string constant is read as text), NULL when the operand can be; any other operand type is reported. The operand must keep its place before IS (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-SQLJSON-MISC. Status: Implemented.

Testing a string for a JSON objectdoctest
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT '{}' IS NOT JSON OBJECT")->toString() // => "SELECT '{}' IS NOT JSON OBJECT"

Properties§

public Scalar $operand
public bool $negated
public JsonUniqueKeys|null $uniqueness = null

Methods§

public function __construct(
    public Scalar $operand,
    public bool $negated,
    public JsonItemKind $kind,
    public JsonUniqueKeys|null $uniqueness = null,
)

Parameters

$operandScalarThe tested value
$negatedboolWhether NOT is written
$kindJsonItemKindThe kind of JSON item tested for
$uniquenessJsonUniqueKeys|nullThe key uniqueness clause, or null when none is written
Calls 4
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operand and checks that it can hold JSON text.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 11
public function render(Output $out): void

Writes the value and the test.

Parameters

$outOutput
Test cases 1
Calls 3

Test cases 9§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4
Other tests reaching this symbol 5

Relations§

Instantiated in 1
Type checks 2
Type declarations 1