diff --git a/src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ObjectToInferredTypesConverter.cs b/src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ObjectToInferredTypesConverter.cs index e22f246fa2..b9711de6e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ObjectToInferredTypesConverter.cs +++ b/src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ObjectToInferredTypesConverter.cs @@ -21,10 +21,11 @@ public override object Read( { JsonTokenType.True => true, JsonTokenType.False => false, - JsonTokenType.Number when reader.TryGetInt64(out var l) => l, + JsonTokenType.Number when reader.TryGetInt64(out var value) => value, JsonTokenType.Number => reader.GetDouble(), - JsonTokenType.String when reader.TryGetDateTime(out var datetime) => datetime, - JsonTokenType.String => reader.GetString(), + JsonTokenType.String when reader.TryGetDateTime(out var value) => value, + JsonTokenType.String when reader.TryGetDateTimeOffset(out var value) => value, + JsonTokenType.String => reader.GetString()!, _ => JsonDocument.ParseValue(ref reader).RootElement.Clone() };