Skip to content

Commit e37f823

Browse files
committed
Change implementation logic
1 parent da26ac7 commit e37f823

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/Destructurama.JsonNet/JsonNet/JsonNetDestructuringPolicy.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,8 @@ private static LogEventPropertyValue Destructure(JArray ja, ILogEventPropertyVal
5252
return new SequenceValue(elems);
5353
}
5454

55-
private static LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyValueFactory propertyValueFactory)
56-
{
57-
return jo.Properties().All(prop => LogEventProperty.IsValidName(prop.Name)) ?
58-
DestructureToStructureValue(jo, propertyValueFactory) :
59-
DestructureToDictionaryValue(jo, propertyValueFactory);
60-
}
6155

62-
private static LogEventPropertyValue DestructureToStructureValue(JObject jo, ILogEventPropertyValueFactory propertyValueFactory)
56+
private static LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyValueFactory propertyValueFactory)
6357
{
6458
string typeTag = null;
6559
var props = new List<LogEventProperty>(jo.Count);
@@ -74,6 +68,10 @@ private static LogEventPropertyValue DestructureToStructureValue(JObject jo, ILo
7468
continue;
7569
}
7670
}
71+
else if (!LogEventProperty.IsValidName(prop.Name))
72+
{
73+
return DestructureToDictionaryValue(jo, propertyValueFactory);
74+
}
7775

7876
props.Add(new LogEventProperty(prop.Name, propertyValueFactory.CreatePropertyValue(prop.Value, true)));
7977
}
@@ -84,11 +82,11 @@ private static LogEventPropertyValue DestructureToStructureValue(JObject jo, ILo
8482
private static LogEventPropertyValue DestructureToDictionaryValue(JObject jo, ILogEventPropertyValueFactory propertyValueFactory)
8583
{
8684
var elements = jo.Properties().Select(
87-
prop =>
88-
new KeyValuePair<ScalarValue, LogEventPropertyValue>(
89-
new ScalarValue(prop.Name),
90-
propertyValueFactory.CreatePropertyValue(prop.Value, true)
91-
)
85+
prop =>
86+
new KeyValuePair<ScalarValue, LogEventPropertyValue>(
87+
new ScalarValue(prop.Name),
88+
propertyValueFactory.CreatePropertyValue(prop.Value, true)
89+
)
9290
);
9391
return new DictionaryValue(elements);
9492
}

0 commit comments

Comments
 (0)