diff --git a/RabbitMQ.EventBus.AspNetCore.Sample/Controllers/ValuesController.cs b/RabbitMQ.EventBus.AspNetCore.Sample/Controllers/ValuesController.cs
index 794778a..a861303 100644
--- a/RabbitMQ.EventBus.AspNetCore.Sample/Controllers/ValuesController.cs
+++ b/RabbitMQ.EventBus.AspNetCore.Sample/Controllers/ValuesController.cs
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc;
-using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
diff --git a/src/RabbitMQ.EventBus.AspNetCore/Extensions/DynamicExtensions.cs b/src/RabbitMQ.EventBus.AspNetCore/Extensions/DynamicExtensions.cs
index 786e312..273f353 100644
--- a/src/RabbitMQ.EventBus.AspNetCore/Extensions/DynamicExtensions.cs
+++ b/src/RabbitMQ.EventBus.AspNetCore/Extensions/DynamicExtensions.cs
@@ -11,10 +11,12 @@ internal static class DynamicExtensions
///
///
///
- public static string Serialize(this TMessage message)
+ public static string Serialize(this TMessage message) => JsonSerializer.Serialize(message, new JsonSerializerOptions
{
- return JsonConvert.SerializeObject(message);
- }
+ PropertyNameCaseInsensitive = true,
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ NumberHandling = JsonNumberHandling.AllowReadingFromString
+ });
///
///
///
@@ -36,7 +38,12 @@ public static TResponse Deserialize(this string message)
{
try
{
- return JsonConvert.DeserializeObject(message);
+ return JsonSerializer.Deserialize(message, new JsonSerializerOptions
+ {
+ PropertyNameCaseInsensitive = true,
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ NumberHandling = JsonNumberHandling.AllowReadingFromString
+ });
}
catch
{
diff --git a/src/RabbitMQ.EventBus.AspNetCore/GlobalUsings.cs b/src/RabbitMQ.EventBus.AspNetCore/GlobalUsings.cs
index 8970fa7..df98285 100644
--- a/src/RabbitMQ.EventBus.AspNetCore/GlobalUsings.cs
+++ b/src/RabbitMQ.EventBus.AspNetCore/GlobalUsings.cs
@@ -1,7 +1,6 @@
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.DependencyInjection.Extensions;
global using Microsoft.Extensions.Logging;
-global using Newtonsoft.Json;
global using Polly;
global using Polly.Retry;
global using RabbitMQ.Client;
@@ -21,6 +20,8 @@
global using System.Linq;
global using System.Net.Sockets;
global using System.Text;
+global using System.Text.Encodings.Web;
+global using System.Text.Json;
+global using System.Text.Json.Serialization;
global using System.Threading;
global using System.Threading.Tasks;
-
diff --git a/src/RabbitMQ.EventBus.AspNetCore/RabbitMQ.EventBus.AspNetCore.csproj b/src/RabbitMQ.EventBus.AspNetCore/RabbitMQ.EventBus.AspNetCore.csproj
index 370e54b..e7e7bd4 100644
--- a/src/RabbitMQ.EventBus.AspNetCore/RabbitMQ.EventBus.AspNetCore.csproj
+++ b/src/RabbitMQ.EventBus.AspNetCore/RabbitMQ.EventBus.AspNetCore.csproj
@@ -26,7 +26,6 @@
-