diff --git a/src/DotNetCore.CAP.Kafka/IConnectionPool.Default.cs b/src/DotNetCore.CAP.Kafka/IConnectionPool.Default.cs index 0271d1d..69d22c5 100644 --- a/src/DotNetCore.CAP.Kafka/IConnectionPool.Default.cs +++ b/src/DotNetCore.CAP.Kafka/IConnectionPool.Default.cs @@ -3,11 +3,11 @@ using System; using System.Collections.Concurrent; -using System.Text.Json; using System.Threading; using Confluent.Kafka; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Newtonsoft.Json; namespace DotNetCore.CAP.Kafka { @@ -24,7 +24,7 @@ namespace DotNetCore.CAP.Kafka _producerPool = new ConcurrentQueue>(); _maxSize = _options.ConnectionPoolSize; - logger.LogDebug("Kafka configuration of CAP :\r\n {0}", JsonSerializer.Serialize(_options.AsKafkaConfig())); + logger.LogDebug("Kafka configuration of CAP :\r\n {0}", JsonConvert.SerializeObject(_options.AsKafkaConfig())); } public string ServersAddress => _options.Servers; diff --git a/src/DotNetCore.CAP/DotNetCore.CAP.csproj b/src/DotNetCore.CAP/DotNetCore.CAP.csproj index b3667f3..2bfc74f 100644 --- a/src/DotNetCore.CAP/DotNetCore.CAP.csproj +++ b/src/DotNetCore.CAP/DotNetCore.CAP.csproj @@ -13,8 +13,8 @@ + - \ No newline at end of file diff --git a/src/DotNetCore.CAP/Serialization/ISerializer.JsonUtf8.cs b/src/DotNetCore.CAP/Serialization/ISerializer.JsonUtf8.cs index 5362342..f638751 100644 --- a/src/DotNetCore.CAP/Serialization/ISerializer.JsonUtf8.cs +++ b/src/DotNetCore.CAP/Serialization/ISerializer.JsonUtf8.cs @@ -1,7 +1,11 @@ -using System; +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Text; using System.Threading.Tasks; using DotNetCore.CAP.Messages; -using System.Text.Json; +using Newtonsoft.Json; namespace DotNetCore.CAP.Serialization { @@ -9,7 +13,8 @@ namespace DotNetCore.CAP.Serialization { public Task SerializeAsync(Message message) { - return Task.FromResult(new TransportMessage(message.Headers, JsonSerializer.SerializeToUtf8Bytes(message.Value))); + var json = JsonConvert.SerializeObject(message.Value); + return Task.FromResult(new TransportMessage(message.Headers, Encoding.UTF8.GetBytes(json))); } public Task DeserializeAsync(TransportMessage transportMessage, Type valueType) @@ -19,7 +24,8 @@ namespace DotNetCore.CAP.Serialization return Task.FromResult(new Message(transportMessage.Headers, null)); } - return Task.FromResult(new Message(transportMessage.Headers, JsonSerializer.Deserialize(transportMessage.Body, valueType))); + var json = Encoding.UTF8.GetString(transportMessage.Body); + return Task.FromResult(new Message(transportMessage.Headers, JsonConvert.DeserializeObject(json, valueType))); } } } diff --git a/src/DotNetCore.CAP/Serialization/ISerializer.cs b/src/DotNetCore.CAP/Serialization/ISerializer.cs index c38d064..0c831f7 100644 --- a/src/DotNetCore.CAP/Serialization/ISerializer.cs +++ b/src/DotNetCore.CAP/Serialization/ISerializer.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; using System.Threading.Tasks; using DotNetCore.CAP.Messages; using JetBrains.Annotations; diff --git a/src/DotNetCore.CAP/Serialization/StringSerializer.cs b/src/DotNetCore.CAP/Serialization/StringSerializer.cs index 8e89111..3c96647 100644 --- a/src/DotNetCore.CAP/Serialization/StringSerializer.cs +++ b/src/DotNetCore.CAP/Serialization/StringSerializer.cs @@ -1,5 +1,8 @@ -using DotNetCore.CAP.Messages; -using System.Text.Json; +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using DotNetCore.CAP.Messages; +using Newtonsoft.Json; namespace DotNetCore.CAP.Serialization { @@ -7,12 +10,12 @@ namespace DotNetCore.CAP.Serialization { public static string Serialize(Message message) { - return JsonSerializer.Serialize(message); + return JsonConvert.SerializeObject(message); } public static Message DeSerialize(string json) { - return JsonSerializer.Deserialize(json); + return JsonConvert.DeserializeObject(json); } } } \ No newline at end of file