Table of Contents

Class DefaultSerializerOptions

Namespace
GenerativeAI
Assembly
GenerativeAI.dll

Represents a class providing default JSON serializer options for consistent serialization and deserialization behavior across the application.

public static class DefaultSerializerOptions
Inheritance
DefaultSerializerOptions
Inherited Members

Remarks

The serializer options include:

  • CamelCase naming policy for property names.
  • Case-insensitive property name matching during deserialization.
  • Automatic serialization of enums as strings.
  • Ignoring null values during serialization.

Properties

CustomJsonTypeResolvers

Gets a list of custom type resolvers used to provide additional or specialized type resolution logic for JSON serialization and deserialization processes.

public static List<IJsonTypeInfoResolver> CustomJsonTypeResolvers { get; }

Property Value

List<IJsonTypeInfoResolver>

Remarks

Custom type resolvers are essential for extending or modifying the default behavior of JSON serialization, enabling support for application-specific or complex data types that may not be adequately handled by the default resolvers. This property is used for compatibility with NativeAOT in JsonMode and QuickTools.

GenerateObjectJsonOptions

Provides a pre-configured instance of JsonSerializerOptions optimized for generating JSON during serialization and deserialization, including custom resolvers and settings for specific cases.

public static JsonSerializerOptions GenerateObjectJsonOptions { get; }

Property Value

JsonSerializerOptions

Remarks

This property adjusts various JSON serialization settings such as default ignore condition, string encoding modes, and options for writing indented JSON. It also integrates custom resolvers and type information to fully support complex serialization demands. In environments where reflection is disabled due to AOT (Ahead-Of-Time compilation) or trimming, the returned options apply specific pre-compiled settings to ensure compatibility and maintain functionality.

Options

Provides a centralized and consistent configuration for JSON serialization and deserialization settings.

public static JsonSerializerOptions Options { get; }

Property Value

JsonSerializerOptions

Remarks

These options are used only for handling serialization for Google Services. It won't be used anywhere else. For specifying custom type resolvers or JsonSerializerContext, use the CustomJsonTypeResolvers property.