diff --git a/src/Protobuf.System.Text.Json/JsonProtobufSerializerOptions.cs b/src/Protobuf.System.Text.Json/JsonProtobufSerializerOptions.cs index 4dc8ed5..6fe6797 100644 --- a/src/Protobuf.System.Text.Json/JsonProtobufSerializerOptions.cs +++ b/src/Protobuf.System.Text.Json/JsonProtobufSerializerOptions.cs @@ -19,4 +19,14 @@ public class JsonProtobufSerializerOptions /// The default value is true. /// public bool TreatDurationAsTimeSpan { get; set; } = true; + + + /// + /// Controls how fields are handled. + /// When set to true, properties will + /// be converted to before serialization and will be expected in the + /// same format as during deserialization. + /// The default value is true. + /// + public bool TreatTimestampAsDateTime { get; set; } = true; } \ No newline at end of file diff --git a/src/Protobuf.System.Text.Json/JsonSerializerOptionsExtensions.cs b/src/Protobuf.System.Text.Json/JsonSerializerOptionsExtensions.cs index de7909e..c36b0c4 100644 --- a/src/Protobuf.System.Text.Json/JsonSerializerOptionsExtensions.cs +++ b/src/Protobuf.System.Text.Json/JsonSerializerOptionsExtensions.cs @@ -19,8 +19,10 @@ public static void AddProtobufSupport(this JsonSerializerOptions options, Action { options.Converters.Add(new DurationConverter()); } - - options.Converters.Add(new TimestampConverter()); + if (jsonProtobufSerializerOptions.TreatTimestampAsDateTime) + { + options.Converters.Add(new TimestampConverter()); + } options.Converters.Add(new ProtobufJsonConverterFactory(jsonProtobufSerializerOptions)); }