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

@ -120,18 +120,18 @@ public partial class ElicitationTests : ClientServerTestBase
Action = "accept",
Content = new Dictionary<string, JsonElement>
{
["prop1"] = (JsonElement)JsonSerializer.Deserialize("""
["prop1"] = JsonElement.Parse("""
"string result"
""", McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonElement)))!,
["prop2"] = (JsonElement)JsonSerializer.Deserialize("""
"""),
["prop2"] = JsonElement.Parse("""
42
""", McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonElement)))!,
["prop3"] = (JsonElement)JsonSerializer.Deserialize("""
"""),
["prop3"] = JsonElement.Parse("""
true
""", McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonElement)))!,
["prop4"] = (JsonElement)JsonSerializer.Deserialize("""
"""),
["prop4"] = JsonElement.Parse("""
"option2"
""", McpJsonUtilities.DefaultOptions.GetTypeInfo(typeof(JsonElement)))!,
"""),
},
};
}