Skip to content

Commit 643bf5a

Browse files
committed
sc
1 parent e70bc42 commit 643bf5a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/System.Linq.Dynamic.Core.NewtonsoftJson/Utils/NormalizeUtils.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ private static void MergeSchema(Dictionary<string, JsonValueInfo> schema, JObjec
5050
{
5151
if (prop.Value is JObject nested)
5252
{
53-
if (!schema.ContainsKey(prop.Name))
53+
if (!schema.TryGetValue(prop.Name, out var jsonValueInfo))
5454
{
55-
schema[prop.Name] = new JsonValueInfo(JTokenType.Object, new Dictionary<string, JsonValueInfo>());
55+
jsonValueInfo = new JsonValueInfo(JTokenType.Object, new Dictionary<string, JsonValueInfo>());
56+
schema[prop.Name] = jsonValueInfo;
5657
}
5758

58-
MergeSchema((Dictionary<string, JsonValueInfo>)schema[prop.Name].Value!, nested);
59+
MergeSchema((Dictionary<string, JsonValueInfo>)jsonValueInfo.Value!, nested);
5960
}
6061
else
6162
{

src/System.Linq.Dynamic.Core.SystemTextJson/Utils/NormalizeUtils.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ private static void MergeSchema(Dictionary<string, JsonValueInfo> schema, JsonOb
6969
{
7070
if (prop.Value is JsonObject nested)
7171
{
72-
if (!schema.ContainsKey(prop.Key))
72+
if (!schema.TryGetValue(prop.Key, out var jsonValueInfo))
7373
{
74-
schema[prop.Key] = new JsonValueInfo(JsonValueKind.Object, new Dictionary<string, JsonValueInfo>());
74+
jsonValueInfo = new JsonValueInfo(JsonValueKind.Object, new Dictionary<string, JsonValueInfo>());
75+
schema[prop.Key] = jsonValueInfo;
7576
}
7677

77-
MergeSchema((Dictionary<string, JsonValueInfo>)schema[prop.Key].Value!, nested);
78+
MergeSchema((Dictionary<string, JsonValueInfo>)jsonValueInfo.Value!, nested);
7879
}
7980
else
8081
{

0 commit comments

Comments
 (0)