Class ProtoJsonRead

Namespace
ProtoTest.Json
Assembly
ProtoTest.Json.dll

The shared JSON read: it parses the document, resolves the optional path, applies the required null checks before the deserializer sees them and deserializes with the shared reader defaults. A protocol keeps only its exception type and its trace vocabulary, supplied through ProtoJsonReadSemantics; every failure is handed to that protocol's trace sink once.

public static class ProtoJsonRead
Inheritance
ProtoJsonRead
Inherited Members

Methods

DescribeRequired<T>(string?)

The required-read name a failure message starts with, for example ReadRequired<Int32>('$.id'); public so a protocol that pre-checks (GraphQL's missing data) names the read the same way the shared helper does.

public static string DescribeRequired<T>(string? jsonPath)

Parameters

jsonPath string

Returns

string

Type Parameters

T

Read<T>(string?, string?, bool, ProtoJsonReadSemantics, JsonSerializerOptions?)

Reads T from json at an optional path. An empty document returns default unless required is set, which fails with the semantics' empty-body reason. A required read also fails when the body, the value at the path or the deserialized result is JSON null. A path that does not resolve throws the semantics' path-miss exception, and a malformed document or a wrong-typed value throws the deserializer's JsonException.

public static T? Read<T>(string? json, string? jsonPath, bool required, ProtoJsonReadSemantics semantics, JsonSerializerOptions? options = null)

Parameters

json string
jsonPath string
required bool
semantics ProtoJsonReadSemantics
options JsonSerializerOptions

Returns

T

Type Parameters

T