Use JsonElement.Parse for string-to-JsonElement deserialization (#1002)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
Copilot 2025-11-21 11:00:11 +02:00 • committed by GitHub
commit a559bfb891
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,7 +81,7 @@ internal static class Program
Params = JsonSerializer.SerializeToNode(new LoggingMessageNotificationParams
{
Level = logLevel,
Data = JsonSerializer.Deserialize<JsonElement>("\"Random log message\"")
Data = JsonElement.Parse("\"Random log message\"")
})
}, cancellationToken);
}
@ -117,7 +117,7 @@ internal static class Program
{
Name = "echo",
Description = "Echoes the input back to the client.",
InputSchema = JsonSerializer.Deserialize<JsonElement>("""
InputSchema = JsonElement.Parse("""
{
"type": "object",
"properties": {
@ -134,17 +134,17 @@ internal static class Program
{
Name = "echoSessionId",
Description = "Echoes the session id back to the client.",
InputSchema = JsonSerializer.Deserialize<JsonElement>("""
InputSchema = JsonElement.Parse("""
{
"type": "object"
}
""", McpJsonUtilities.DefaultOptions),
"""),
},
new Tool
{
Name = "sampleLLM",
Description = "Samples from an LLM using MCP's sampling feature.",
InputSchema = JsonSerializer.Deserialize<JsonElement>("""
InputSchema = JsonElement.Parse("""
{
"type": "object",
"properties": {