Table of Contents

Class CellJsonCodec<T>

Namespace
KernLab.Cell.Contracts
Assembly
KernLab.Cell.Contracts.dll

canonical JSON 管道(Json——内建缺省,§3.5): 使用方自带 JsonTypeInfo<T>(JsonSerializerContext 产物)即 AOT 安全,Loom.Http 同款先例。

★ canonical=UTF-8、无缩进、无 BOM、属性名由使用方 context 冻结(声明序/原样名)——逐字可对拍; 缩进形态的 context 在此拒绝(canonical 破坏=配置错误,fail-fast 不自欺)。

public sealed class CellJsonCodec<T> : ICellCodec<T>

Type Parameters

T

载荷类型。

Inheritance
CellJsonCodec<T>
Implements
Inherited Members

Constructors

CellJsonCodec(JsonTypeInfo<T>)

构造(context 缺省形态=MyContext.Default.MyType)。

public CellJsonCodec(JsonTypeInfo<T> typeInfo)

Parameters

typeInfo JsonTypeInfo<T>

Methods

Encode(T, IBufferWriter<byte>)

编码到零拷贝汇(UTF-8;net8 的 typeInfo 直写口走 Utf8JsonWriter——IBufferWriter 重载 STJ9 才有)。

public void Encode(T value, IBufferWriter<byte> output)

Parameters

value T
output IBufferWriter<byte>

TryDecode(ReadOnlySpan<byte>, out T)

原位解码(UTF-8)。畸形 JSON=false(硬解析纪律)。

public bool TryDecode(ReadOnlySpan<byte> encoded, out T value)

Parameters

encoded ReadOnlySpan<byte>
value T

Returns

bool