Skip to content

Commit 004fa39

Browse files
committed
Revert "Use JsonNode instead of JsonDocument"
This reverts commit 4dbe411.
1 parent 4dbe411 commit 004fa39

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System;
2222
using System.Collections.Generic;
2323
using System.Text.Json;
24-
using System.Text.Json.Nodes;
2524
using System.Text.Json.Serialization;
2625

2726
#nullable enable
@@ -32,9 +31,8 @@ internal class GetClientWindowsResultConverter : JsonConverter<GetClientWindowsR
3231
{
3332
public override GetClientWindowsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3433
{
35-
var jsonNode = JsonNode.Parse(ref reader);
36-
37-
var clientWindows = jsonNode?["clientWindows"].Deserialize<IReadOnlyList<ClientWindowInfo>>(options);
34+
using var doc = JsonDocument.ParseValue(ref reader);
35+
var clientWindows = doc.RootElement.GetProperty("clientWindows").Deserialize<IReadOnlyList<ClientWindowInfo>>(options);
3836

3937
return new GetClientWindowsResult(clientWindows!);
4038
}

dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetCookiesResultConverter.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System;
2222
using System.Collections.Generic;
2323
using System.Text.Json;
24-
using System.Text.Json.Nodes;
2524
using System.Text.Json.Serialization;
2625

2726
#nullable enable
@@ -32,10 +31,9 @@ internal class GetCookiesResultConverter : JsonConverter<GetCookiesResult>
3231
{
3332
public override GetCookiesResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3433
{
35-
var jsonNode = JsonNode.Parse(ref reader);
36-
37-
var cookies = jsonNode?["cookies"].Deserialize<IReadOnlyList<Modules.Network.Cookie>>(options);
38-
var partitionKey = jsonNode?["partitionKey"].Deserialize<PartitionKey>(options);
34+
using var doc = JsonDocument.ParseValue(ref reader);
35+
var cookies = doc.RootElement.GetProperty("cookies").Deserialize<IReadOnlyList<Modules.Network.Cookie>>(options);
36+
var partitionKey = doc.RootElement.GetProperty("partitionKey").Deserialize<PartitionKey>(options);
3937

4038
return new GetCookiesResult(cookies!, partitionKey!);
4139
}

dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetRealmsResultConverter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System;
2222
using System.Collections.Generic;
2323
using System.Text.Json;
24-
using System.Text.Json.Nodes;
2524
using System.Text.Json.Serialization;
2625

2726
#nullable enable
@@ -32,9 +31,8 @@ internal class GetRealmsResultConverter : JsonConverter<GetRealmsResult>
3231
{
3332
public override GetRealmsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3433
{
35-
var jsonNode = JsonNode.Parse(ref reader);
36-
37-
var realms = jsonNode?["realms"].Deserialize<IReadOnlyList<RealmInfo>>(options);
34+
using var doc = JsonDocument.ParseValue(ref reader);
35+
var realms = doc.RootElement.GetProperty("realms").Deserialize<IReadOnlyList<RealmInfo>>(options);
3836

3937
return new GetRealmsResult(realms!);
4038
}

dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/GetUserContextsResultConverter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using System;
2222
using System.Collections.Generic;
2323
using System.Text.Json;
24-
using System.Text.Json.Nodes;
2524
using System.Text.Json.Serialization;
2625

2726
#nullable enable
@@ -32,9 +31,8 @@ internal class GetUserContextsResultConverter : JsonConverter<GetUserContextsRes
3231
{
3332
public override GetUserContextsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3433
{
35-
var jsonNode = JsonNode.Parse(ref reader);
36-
37-
var userContexts = jsonNode?["userContexts"].Deserialize<IReadOnlyList<UserContextInfo>>(options);
34+
using var doc = JsonDocument.ParseValue(ref reader);
35+
var userContexts = doc.RootElement.GetProperty("userContexts").Deserialize<IReadOnlyList<UserContextInfo>>(options);
3836

3937
return new GetUserContextsResult(userContexts!);
4038
}

dotnet/src/webdriver/BiDi/Communication/Json/Converters/Enumerable/LocateNodesResultConverter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
using System;
2323
using System.Collections.Generic;
2424
using System.Text.Json;
25-
using System.Text.Json.Nodes;
2625
using System.Text.Json.Serialization;
2726

2827
#nullable enable
@@ -33,9 +32,8 @@ internal class LocateNodesResultConverter : JsonConverter<LocateNodesResult>
3332
{
3433
public override LocateNodesResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3534
{
36-
var jsonNode = JsonNode.Parse(ref reader);
37-
38-
var nodes = jsonNode?["qwe"].Deserialize<IReadOnlyList<RemoteValue.Node>>(options);
35+
using var doc = JsonDocument.ParseValue(ref reader);
36+
var nodes = doc.RootElement.GetProperty("nodes").Deserialize<IReadOnlyList<RemoteValue.Node>>(options);
3937

4038
return new LocateNodesResult(nodes!);
4139
}

0 commit comments

Comments
 (0)