diff --git a/dotnet/src/SemanticKernel.Abstractions/Functions/KernelJsonSchema.cs b/dotnet/src/SemanticKernel.Abstractions/Functions/KernelJsonSchema.cs
index b8677fae62..c7e74f2ac9 100644
--- a/dotnet/src/SemanticKernel.Abstractions/Functions/KernelJsonSchema.cs
+++ b/dotnet/src/SemanticKernel.Abstractions/Functions/KernelJsonSchema.cs
@@ -14,6 +14,8 @@ public sealed class KernelJsonSchema
{
/// Converter for serializing/deserializing JsonSchema instances.
private static readonly SchemaJsonConverter s_jsonSchemaConverter = new();
+ /// Serialization settings for
+ private static readonly JsonSerializerOptions s_jsonSerializerOptions = new() { MaxDepth = 128 };
/// The schema stored as a string.
private string? _schemaAsString;
@@ -21,7 +23,7 @@ public sealed class KernelJsonSchema
/// The JSON Schema as a string.
/// A parsed , or null if is null or empty.
internal static KernelJsonSchema? ParseOrNull(string? jsonSchema) =>
- !string.IsNullOrEmpty(jsonSchema) ? new(JsonSerializer.Deserialize(jsonSchema!)) :
+ !string.IsNullOrEmpty(jsonSchema) ? new(JsonSerializer.Deserialize(jsonSchema!, s_jsonSerializerOptions)) :
null;
/// Parses a JSON Schema for a parameter type.
@@ -30,21 +32,21 @@ public sealed class KernelJsonSchema
/// is null.
/// The JSON is invalid.
public static KernelJsonSchema Parse(string jsonSchema) =>
- new(JsonSerializer.SerializeToElement(JsonSchema.FromText(jsonSchema)));
+ new(JsonSerializer.SerializeToElement(JsonSchema.FromText(jsonSchema, s_jsonSerializerOptions), s_jsonSerializerOptions));
/// Parses a JSON Schema for a parameter type.
/// The JSON Schema as a sequence of UTF16 chars.
/// A parsed .
/// The JSON is invalid.
public static KernelJsonSchema Parse(ReadOnlySpan jsonSchema) =>
- new(JsonSerializer.SerializeToElement(JsonSerializer.Deserialize(jsonSchema)));
+ new(JsonSerializer.SerializeToElement(JsonSerializer.Deserialize(jsonSchema, s_jsonSerializerOptions), s_jsonSerializerOptions));
/// Parses a JSON Schema for a parameter type.
/// The JSON Schema as a sequence of UTF8 bytes.
/// A parsed .
/// The JSON is invalid.
public static KernelJsonSchema Parse(ReadOnlySpan utf8JsonSchema) =>
- new(JsonSerializer.SerializeToElement(JsonSerializer.Deserialize(utf8JsonSchema)));
+ new(JsonSerializer.SerializeToElement(JsonSerializer.Deserialize(utf8JsonSchema, s_jsonSerializerOptions), s_jsonSerializerOptions));
/// Initializes a new instance from the specified .
/// The schema to be stored.