Table of Contents

Class BoolFromStringConverter

Namespace
Crews.PlanningCenter.Api.Converters
Assembly
Crews.PlanningCenter.Api.dll

A custom JSON converter that handles boolean values represented as strings in the JSON payload.

public class BoolFromStringConverter : JsonConverter<bool>
Inheritance
BoolFromStringConverter
Inherited Members

Constructors

BoolFromStringConverter()

public BoolFromStringConverter()

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads a boolean value from a JSON string. Accepts "true", "false", "1", and "0" (case-insensitive) as valid inputs.

public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The JSON reader to read from.

typeToConvert Type

The type to convert to.

options JsonSerializerOptions

The JSON serializer options.

Returns

bool

The converted boolean value.

Exceptions

JsonException

Thrown when the value cannot be converted to a boolean.

Write(Utf8JsonWriter, bool, JsonSerializerOptions)

Writes a boolean value as a JSON boolean. This converter does not support writing boolean values as strings.

public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The JSON writer to write to.

value bool

The boolean value to write.

options JsonSerializerOptions

The JSON serializer options.