Skip to main content

Definition

Assembly: CloudNimble.ClaudeEssentials.dll Namespace: CloudNimble.ClaudeEssentials.Hooks Inheritance: System.Text.Json.Serialization.JsonSerializerContext

Syntax

CloudNimble.ClaudeEssentials.Hooks.ClaudeHooksJsonContext

Summary

Provides AOT-compatible JSON serialization context for Claude Code hook types. This context uses source generators to pre-compile serialization code, eliminating the need for runtime reflection.

Usage

ClaudeHooksJsonContext is a source-generated JsonSerializerContext that enables AOT-compatible JSON serialization.

Direct Usage

using System.Text.Json;

// Deserialize using the context directly
var input = JsonSerializer.Deserialize(
    json, 
    ClaudeHooksJsonContext.Default.PreToolUseHookInputObject);

// Serialize using the context directly
string output = JsonSerializer.Serialize(
    hookOutput,
    ClaudeHooksJsonContext.Default.PostToolUseHookOutput);

Accessing Options

// Get the configured JsonSerializerOptions
JsonSerializerOptions options = ClaudeHooksJsonContext.Default.Options;

Extending for Custom Types

Create your own context for strongly-typed tool inputs:
[JsonSerializable(typeof(PreToolUseHookInput<BashToolInput>))]
[JsonSerializable(typeof(PreToolUseHookInput<WriteToolInput>))]
public partial class MyHooksJsonContext : JsonSerializerContext { }

Remarks

For generic hook types (PreToolUseHookInput, PostToolUseHookInput, etc.), this context registers versions using Object as the type parameter. If you need strongly-typed serialization for specific tool inputs/outputs, create your own JsonSerializerContext with additional type registrations. Usage example:
var input = JsonSerializer.Deserialize(json, ClaudeHooksJsonContext.Default.PreToolUseHookInputObject);
var output = JsonSerializer.Serialize(hookOutput, ClaudeHooksJsonContext.Default.PreToolUseHookOutputObject);

Constructors

.ctor

Syntax

public ClaudeHooksJsonContext()

.ctor

Syntax

public ClaudeHooksJsonContext(System.Text.Json.JsonSerializerOptions options)

Parameters

NameTypeDescription
optionsSystem.Text.Json.JsonSerializerOptions-

Properties

Boolean

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<bool> Boolean { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<bool>

CompactTrigger

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.CompactTrigger> CompactTrigger { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.CompactTrigger>

Default

The default JsonSerializerContext associated with a default JsonSerializerOptions instance.

Syntax

public static CloudNimble.ClaudeEssentials.Hooks.ClaudeHooksJsonContext Default { get; }

Property Value

Type: CloudNimble.ClaudeEssentials.Hooks.ClaudeHooksJsonContext

HookDecision

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.HookDecision> HookDecision { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.HookDecision>

HookEventName

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.HookEventName> HookEventName { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.HookEventName>

JsonElement

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<System.Text.Json.JsonElement> JsonElement { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<System.Text.Json.JsonElement>

NotificationHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.NotificationHookInput> NotificationHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.NotificationHookInput>

NotificationHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.NotificationHookOutput> NotificationHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.NotificationHookOutput>

NotificationType

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.NotificationType> NotificationType { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.NotificationType>

NullableHookDecision

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<System.Nullable<CloudNimble.ClaudeEssentials.Hooks.Enums.HookDecision>> NullableHookDecision { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<System.Nullable<CloudNimble.ClaudeEssentials.Hooks.Enums.HookDecision>>

NullablePermissionDecision

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<System.Nullable<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionDecision>> NullablePermissionDecision { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<System.Nullable<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionDecision>>

Object

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<object> Object { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<object>

PermissionDecision

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionDecision> PermissionDecision { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionDecision>

PermissionMode

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionMode> PermissionMode { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionMode>

PermissionRequestBehavior

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionRequestBehavior> PermissionRequestBehavior { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.PermissionRequestBehavior>

PermissionRequestDecisionObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PermissionRequestDecision<object>> PermissionRequestDecisionObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PermissionRequestDecision<object>>

PermissionRequestHookInputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PermissionRequestHookInput<object>> PermissionRequestHookInputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PermissionRequestHookInput<object>>

PermissionRequestHookOutputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PermissionRequestHookOutput<object>> PermissionRequestHookOutputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PermissionRequestHookOutput<object>>

PermissionRequestSpecificOutputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PermissionRequestSpecificOutput<object>> PermissionRequestSpecificOutputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PermissionRequestSpecificOutput<object>>

PostToolUseHookInputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PostToolUseHookInput<object, object>> PostToolUseHookInputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PostToolUseHookInput<object, object>>

PostToolUseHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PostToolUseHookOutput> PostToolUseHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PostToolUseHookOutput>

PostToolUseSpecificOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PostToolUseSpecificOutput> PostToolUseSpecificOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PostToolUseSpecificOutput>

PreCompactHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PreCompactHookInput> PreCompactHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PreCompactHookInput>

PreCompactHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PreCompactHookOutput> PreCompactHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PreCompactHookOutput>

PreToolUseHookInputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PreToolUseHookInput<object>> PreToolUseHookInputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.PreToolUseHookInput<object>>

PreToolUseHookOutputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PreToolUseHookOutput<object>> PreToolUseHookOutputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PreToolUseHookOutput<object>>

PreToolUseSpecificOutputObject

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PreToolUseSpecificOutput<object>> PreToolUseSpecificOutputObject { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.PreToolUseSpecificOutput<object>>

SessionEndHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.SessionEndHookInput> SessionEndHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.SessionEndHookInput>

SessionEndHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SessionEndHookOutput> SessionEndHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SessionEndHookOutput>

SessionEndReason

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.SessionEndReason> SessionEndReason { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.SessionEndReason>

SessionStartHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.SessionStartHookInput> SessionStartHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.SessionStartHookInput>

SessionStartHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SessionStartHookOutput> SessionStartHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SessionStartHookOutput>

SessionStartSource

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.SessionStartSource> SessionStartSource { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Enums.SessionStartSource>

SessionStartSpecificOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SessionStartSpecificOutput> SessionStartSpecificOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SessionStartSpecificOutput>

StopHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.StopHookInput> StopHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.StopHookInput>

StopHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.StopHookOutput> StopHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.StopHookOutput>

String

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<string> String { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<string>

SubagentStopHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.SubagentStopHookInput> SubagentStopHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.SubagentStopHookInput>

SubagentStopHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SubagentStopHookOutput> SubagentStopHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.SubagentStopHookOutput>

UserPromptSubmitHookInput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.UserPromptSubmitHookInput> UserPromptSubmitHookInput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Inputs.UserPromptSubmitHookInput>

UserPromptSubmitHookOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.UserPromptSubmitHookOutput> UserPromptSubmitHookOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.UserPromptSubmitHookOutput>

UserPromptSubmitSpecificOutput

Defines the source generated JSON serialization contract metadata for a given type.

Syntax

public System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.UserPromptSubmitSpecificOutput> UserPromptSubmitSpecificOutput { get; }

Property Value

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo<CloudNimble.ClaudeEssentials.Hooks.Outputs.UserPromptSubmitSpecificOutput>

Methods

GetTypeInfo Override

Syntax

public override System.Text.Json.Serialization.Metadata.JsonTypeInfo GetTypeInfo(System.Type type)

Parameters

NameTypeDescription
typeSystem.Type-

Returns

Type: System.Text.Json.Serialization.Metadata.JsonTypeInfo?
  • System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver