File tree Expand file tree Collapse file tree
RabbitMQ.EventBus.AspNetCore.Sample/Controllers
src/RabbitMQ.EventBus.AspNetCore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Microsoft . AspNetCore . Mvc ;
2- using Newtonsoft . Json ;
32using System ;
43using System . Threading . Tasks ;
54
Original file line number Diff line number Diff line change @@ -11,10 +11,12 @@ internal static class DynamicExtensions
1111 /// <typeparam name="TMessage"></typeparam>
1212 /// <param name="message"></param>
1313 /// <returns></returns>
14- public static string Serialize < TMessage > ( this TMessage message )
14+ public static string Serialize < TMessage > ( this TMessage message ) => JsonSerializer . Serialize ( message , new JsonSerializerOptions
1515 {
16- return JsonConvert . SerializeObject ( message ) ;
17- }
16+ PropertyNameCaseInsensitive = true ,
17+ Encoder = JavaScriptEncoder . UnsafeRelaxedJsonEscaping ,
18+ NumberHandling = JsonNumberHandling . AllowReadingFromString
19+ } ) ;
1820 /// <summary>
1921 ///
2022 /// </summary>
@@ -36,7 +38,12 @@ public static TResponse Deserialize<TResponse>(this string message)
3638 {
3739 try
3840 {
39- return JsonConvert . DeserializeObject < TResponse > ( message ) ;
41+ return JsonSerializer . Deserialize < TResponse > ( message , new JsonSerializerOptions
42+ {
43+ PropertyNameCaseInsensitive = true ,
44+ Encoder = JavaScriptEncoder . UnsafeRelaxedJsonEscaping ,
45+ NumberHandling = JsonNumberHandling . AllowReadingFromString
46+ } ) ;
4047 }
4148 catch
4249 {
Original file line number Diff line number Diff line change 11global using Microsoft . Extensions . DependencyInjection ;
22global using Microsoft . Extensions . DependencyInjection . Extensions ;
33global using Microsoft . Extensions . Logging ;
4- global using Newtonsoft . Json ;
54global using Polly ;
65global using Polly . Retry ;
76global using RabbitMQ . Client ;
2120global using System . Linq ;
2221global using System . Net . Sockets ;
2322global using System . Text ;
23+ global using System . Text . Encodings . Web ;
24+ global using System . Text . Json ;
25+ global using System . Text . Json . Serialization ;
2426global using System . Threading ;
2527global using System . Threading . Tasks ;
26-
Original file line number Diff line number Diff line change 2626 <PackageReference Include =" Microsoft.Extensions.DependencyInjection" Version =" 6.0.0" />
2727 <PackageReference Include =" Microsoft.Extensions.DependencyInjection.Abstractions" Version =" 6.0.0" />
2828 <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 6.0.1" />
29- <PackageReference Include =" Newtonsoft.Json" Version =" 13.0.2" />
3029 <PackageReference Include =" Polly" Version =" 7.2.3" />
3130 <PackageReference Include =" RabbitMQ.Client" Version =" 6.4.0" />
3231 </ItemGroup >
You can’t perform that action at this time.
0 commit comments