@@ -54,8 +54,10 @@ public static IMessageSerializer With(
54
54
}
55
55
56
56
class MessageSerializer ( SchemaRegistry schemaRegistry ) : IMessageSerializer {
57
- readonly ISerializer _jsonSerializer =
58
- schemaRegistry . GetSerializer ( ContentType . Json ) ;
57
+ readonly SystemTextJsonSerializer _metadataSerializer =
58
+ new SystemTextJsonSerializer (
59
+ new SystemTextJsonSerializationSettings { Options = KurrentDBClient . StreamMetadataJsonSerializerOptions }
60
+ ) ;
59
61
60
62
readonly IMessageTypeNamingStrategy _messageTypeNamingStrategy =
61
63
schemaRegistry . MessageTypeNamingStrategy ;
@@ -74,7 +76,7 @@ public EventData Serialize(Message message, MessageSerializationContext serializ
74
76
. Serialize ( data ) ;
75
77
76
78
var serializedMetadata = metadata != null
77
- ? _jsonSerializer . Serialize ( metadata )
79
+ ? _metadataSerializer . Serialize ( metadata )
78
80
: ReadOnlyMemory < byte > . Empty ;
79
81
80
82
return new EventData (
@@ -106,8 +108,8 @@ public bool TryDeserialize(EventRecord record, [NotNullWhen(true)] out Message?
106
108
}
107
109
108
110
object ? metadata = record . Metadata . Length > 0 && TryResolveClrMetadataType ( record , out var clrMetadataType )
109
- ? _jsonSerializer . Deserialize ( record . Metadata , clrMetadataType ! )
110
- : null ;
111
+ ? _metadataSerializer . Deserialize ( record . Metadata , clrMetadataType ! )
112
+ : null ;
111
113
112
114
deserialized = Message . From ( data , metadata , record . EventId ) ;
113
115
return true ;
0 commit comments