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>
Constructors
Section titled “Constructors”PgJson(string)
Section titled “PgJson(string)”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.
Methods
Section titled “Methods”Deserialize<T>(JsonTypeInfo<T>)
Section titled “Deserialize<T>(JsonTypeInfo<T>)”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.
Equals(PgJson)
Section titled “Equals(PgJson)”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.
Equals(object)
Section titled “Equals(object)”public override bool Equals(object obj)Parameters:
obj — object
Returns: bool
GetHashCode()
Section titled “GetHashCode()”Gets an ordinal text hash consistent with equality.
public override int GetHashCode()Returns: int
The text hash.
Parse()
Section titled “Parse()”Parses an independently owned document. The caller must dispose it after use.
public JsonDocument Parse()Returns: JsonDocument
The owned JSON document.
Serialize<T>(T, JsonTypeInfo<T>)
Section titled “Serialize<T>(T, JsonTypeInfo<T>)”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.
ToString()
Section titled “ToString()”Returns the original JSON text.
public override string ToString()Returns: string
The JSON text.
Properties
Section titled “Properties”Gets the original JSON text, or null’s JSON spelling for the default value.
public string Text { get; }Value: string
Operators
Section titled “Operators”operator ==(PgJson, PgJson)
Section titled “operator ==(PgJson, PgJson)”public static bool operator ==(PgJson left, PgJson right)Parameters:
left — PgJson
right — PgJson
Returns: bool
operator !=(PgJson, PgJson)
Section titled “operator !=(PgJson, PgJson)”public static bool operator !=(PgJson left, PgJson right)Parameters:
left — PgJson
right — PgJson
Returns: bool