Skip to content

PgJsonb

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns the text representation of a PostgreSQL jsonb value. PostgreSQL normalizes it when constructing the native datum. The default value represents JSON null; use PgJsonb? for SQL NULL. Managed equality compares text ordinally.

[JsonConverter(typeof(PgJsonbConverter))]
public readonly struct PgJsonb : IEquatable<PgJsonb>

Implements: IEquatable<PgJsonb>

Creates a syntactically valid JSON value. PostgreSQL applies its additional jsonb constraints at the native boundary.

public PgJsonb(string text)

Parameters:

text — string

One complete JSON value.

Deserializes this value using explicit metadata suitable for Native AOT.

public T? Deserialize<T>(JsonTypeInfo<T> typeInfo)

Type parameters:

T

The target managed type.

Parameters:

typeInfo — JsonTypeInfo<T>

Usually a source-generated serialization context’s type metadata.

Returns: T

The deserialized value.

Compares the stored text. Use PostgreSQL jsonb operators when structural SQL equality is required.

public bool Equals(PgJsonb other)

Parameters:

other — PgJsonb

The other value.

Returns: bool

Whether both values contain the same text.

public override bool Equals(object obj)

Parameters:

obj — object

Returns: bool

Gets an ordinal text hash consistent with equality.

public override int GetHashCode()

Returns: int

The text hash.

Parses an independently owned document. The caller must dispose it after use.

public JsonDocument Parse()

Returns: JsonDocument

The owned JSON document.

Serializes a managed value using explicit metadata suitable for Native AOT.

public static PgJsonb Serialize<T>(T value, JsonTypeInfo<T> typeInfo)

Type parameters:

T

The managed type.

Parameters:

value — T

The value to serialize.

typeInfo — JsonTypeInfo<T>

The serialization metadata.

Returns: PgJsonb

An owned JSONB value.

Returns the JSON text.

public override string ToString()

Returns: string

The JSON text.

Gets the JSON text. Values read from PostgreSQL use PostgreSQL’s normalized jsonb output format.

public string Text { get; }

Value: string

public static bool operator ==(PgJsonb left, PgJsonb right)

Parameters:

left — PgJsonb

right — PgJsonb

Returns: bool

public static bool operator !=(PgJsonb left, PgJsonb right)

Parameters:

left — PgJsonb

right — PgJsonb

Returns: bool