in src/Elastic.CommonSchema/Serialization/EcsDocumentJsonConverter.cs [17:60]
public override TBase? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
{
reader.Read();
return null;
}
if (reader.TokenType != JsonTokenType.StartObject)
throw new JsonException();
var ecsEvent = new TBase();
string? loglevel = null;
string? ecsVersion = null;
DateTimeOffset? timestamp = default;
var originalDepth = reader.CurrentDepth;
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
if (reader.CurrentDepth <= originalDepth)
break;
continue;
}
if (reader.TokenType != JsonTokenType.PropertyName)
throw new JsonException();
var _ = ReadProperties(ref reader, ecsEvent, ref timestamp, ref loglevel, ref ecsVersion, options);
}
if (!string.IsNullOrEmpty(loglevel))
{
ecsEvent.Log ??= new Log();
ecsEvent.Log.Level = loglevel;
}
if (!string.IsNullOrEmpty(ecsVersion))
{
ecsEvent.Ecs ??= new Ecs();
ecsEvent.Ecs.Version = ecsVersion;
}
ecsEvent.Timestamp = timestamp;
return ecsEvent;
}