Skip to content

PgJson

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns PostgreSQL json text, preserving whitespace, key order, duplicate keys, and numeric spelling. The default value represents JSON null; use PgJson? to represent SQL NULL. Equality compares the text ordinally.

[JsonConverter(typeof(PgJsonConverter))]
public readonly struct PgJson : IEquatable<PgJson>

Implements: IEquatable<PgJson>

Creates a JSON value after validating its syntax without converting numeric tokens to floating-point values.

public PgJson(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 exact JSON text, without imposing PostgreSQL jsonb structural equality.

public bool Equals(PgJson other)

Parameters:

other — PgJson

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 PgJson 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: PgJson

An owned JSON value.

Returns the original JSON text.

public override string ToString()

Returns: string

The JSON text.

Gets the original JSON text, or null’s JSON spelling for the default value.

public string Text { get; }

Value: string

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

Parameters:

left — PgJson

right — PgJson

Returns: bool

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

Parameters:

left — PgJson

right — PgJson

Returns: bool