-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1470 from preardon/feature/1457-RemoveNewtonsoft
Replaced NewtonSoft.Json with System.Text.Json #1457
- Loading branch information
Showing
115 changed files
with
480 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
/* The MIT License (MIT) | ||
Copyright © 2014 Ian Cooper <[email protected]> | ||
|
@@ -22,8 +22,8 @@ THE SOFTWARE. */ | |
|
||
#endregion | ||
|
||
using System.Text.Json; | ||
using Greetings.Ports.Commands; | ||
using Newtonsoft.Json; | ||
using Paramore.Brighter; | ||
using Paramore.Brighter.MessagingGateway.AWSSQS; | ||
|
||
|
@@ -34,14 +34,14 @@ public class GreetingEventMessageMapper : IAmAMessageMapper<GreetingEvent> | |
public Message MapToMessage(GreetingEvent request) | ||
{ | ||
var header = new MessageHeader(messageId: request.Id, topic: typeof(GreetingEvent).FullName.ToValidSNSTopicName(), messageType: MessageType.MT_EVENT); | ||
var body = new MessageBody(JsonConvert.SerializeObject(request)); | ||
var body = new MessageBody(JsonSerializer.Serialize(request, JsonSerialisationOptions.Options)); | ||
var message = new Message(header, body); | ||
return message; | ||
} | ||
|
||
public GreetingEvent MapToRequest(Message message) | ||
{ | ||
var greetingCommand = JsonConvert.DeserializeObject<GreetingEvent>(message.Body.Value); | ||
var greetingCommand = JsonSerializer.Deserialize<GreetingEvent>(message.Body.Value, JsonSerialisationOptions.Options); | ||
|
||
return greetingCommand; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
/* The MIT License (MIT) | ||
Copyright © 2014 Ian Cooper <[email protected]> | ||
|
@@ -22,8 +22,8 @@ THE SOFTWARE. */ | |
|
||
#endregion | ||
|
||
using System.Text.Json; | ||
using KafkaTaskQueueSamples.Greetings.Ports.Commands; | ||
using Newtonsoft.Json; | ||
using Paramore.Brighter; | ||
|
||
namespace KafkaTaskQueueSamples.Greetings.Ports.Mappers | ||
|
@@ -33,14 +33,14 @@ public class GreetingEventMessageMapper : IAmAMessageMapper<GreetingEvent> | |
public Message MapToMessage(GreetingEvent request) | ||
{ | ||
var header = new MessageHeader(messageId: request.Id, topic: "greeting.event", messageType: MessageType.MT_EVENT); | ||
var body = new MessageBody(JsonConvert.SerializeObject(request)); | ||
var body = new MessageBody(JsonSerializer.Serialize(request, JsonSerialisationOptions.Options)); | ||
var message = new Message(header, body); | ||
return message; | ||
} | ||
|
||
public GreetingEvent MapToRequest(Message message) | ||
{ | ||
var greetingCommand = JsonConvert.DeserializeObject<GreetingEvent>(message.Body.Value); | ||
var greetingCommand = JsonSerializer.Deserialize<GreetingEvent>(message.Body.Value, JsonSerialisationOptions.Options); | ||
|
||
return greetingCommand; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
/* The MIT License (MIT) | ||
Copyright © 2014 Ian Cooper <[email protected]> | ||
|
@@ -22,8 +22,8 @@ THE SOFTWARE. */ | |
|
||
#endregion | ||
|
||
using System.Text.Json; | ||
using Events.Ports.Commands; | ||
using Newtonsoft.Json; | ||
using Paramore.Brighter; | ||
|
||
namespace Events.Ports.Mappers | ||
|
@@ -33,14 +33,14 @@ public class GreetingEventMessageMapper : IAmAMessageMapper<GreetingEvent> | |
public Message MapToMessage(GreetingEvent request) | ||
{ | ||
var header = new MessageHeader(messageId: request.Id, topic: "greeting.event", messageType: MessageType.MT_EVENT); | ||
var body = new MessageBody(JsonConvert.SerializeObject(request)); | ||
var body = new MessageBody(JsonSerializer.Serialize(request, JsonSerialisationOptions.Options)); | ||
var message = new Message(header, body); | ||
return message; | ||
} | ||
|
||
public GreetingEvent MapToRequest(Message message) | ||
{ | ||
var greetingCommand = JsonConvert.DeserializeObject<GreetingEvent>(message.Body.Value); | ||
var greetingCommand = JsonSerializer.Deserialize<GreetingEvent>(message.Body.Value, JsonSerialisationOptions.Options); | ||
|
||
return greetingCommand; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
/* The MIT License (MIT) | ||
Copyright © 2014 Ian Cooper <[email protected]> | ||
|
@@ -23,8 +23,8 @@ THE SOFTWARE. */ | |
#endregion | ||
|
||
using System; | ||
using System.Text.Json; | ||
using Greetings.Ports.Commands; | ||
using Newtonsoft.Json.Linq; | ||
using Paramore.Brighter; | ||
|
||
namespace Greetings.Ports.Mappers | ||
|
@@ -40,12 +40,7 @@ public Message MapToMessage(GreetingRequest request) | |
correlationId: request.ReplyAddress.CorrelationId, | ||
replyTo: request.ReplyAddress.Topic); | ||
|
||
var json = new JObject( | ||
new JProperty("Id", request.Id), | ||
new JProperty("Name", request.Name), | ||
new JProperty("Language", request.Language) | ||
); | ||
var body = new MessageBody(json.ToString()); | ||
var body = new MessageBody(JsonSerializer.Serialize(new GreetingsRequestBody(request.Id.ToString(), request.Name, request.Language), JsonSerialisationOptions.Options)); | ||
var message = new Message(header, body); | ||
return message; | ||
|
||
|
@@ -55,9 +50,9 @@ public GreetingRequest MapToRequest(Message message) | |
{ | ||
var replyAddress = new ReplyAddress(topic: message.Header.ReplyTo, correlationId: message.Header.CorrelationId); | ||
var command = new GreetingRequest(replyAddress); | ||
var body = JObject.Parse(message.Body.Value); | ||
command.Name = Convert.ToString(body["Name"]); | ||
command.Language = Convert.ToString(body["Language"]); | ||
var body = JsonSerializer.Deserialize<GreetingsRequestBody>(message.Body.Value, JsonSerialisationOptions.Options); | ||
command.Name = body.Name; | ||
command.Language = body.Language; | ||
return command; | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
samples/RMQRequestReplyExamples/Greetings/Ports/Mappers/GreetingsReplyBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Greetings.Ports.Mappers | ||
{ | ||
public class GreetingsReplyBody | ||
{ | ||
public string Id { get; set; } | ||
public string Salutation { get; set; } | ||
|
||
public GreetingsReplyBody(string id, string salutation) | ||
{ | ||
Id = id; | ||
Salutation = salutation; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
samples/RMQRequestReplyExamples/Greetings/Ports/Mappers/GreetingsRequestBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Greetings.Ports.Mappers | ||
{ | ||
public class GreetingsRequestBody | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
public string Language { get; set; } | ||
|
||
public GreetingsRequestBody (string id, string name, string language) | ||
{ | ||
Id = id; | ||
Name = name; | ||
Language = language; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
/* The MIT License (MIT) | ||
Copyright © 2014 Ian Cooper <[email protected]> | ||
|
@@ -22,8 +22,8 @@ THE SOFTWARE. */ | |
|
||
#endregion | ||
|
||
using System.Text.Json; | ||
using Greetings.Ports.Commands; | ||
using Newtonsoft.Json; | ||
using Paramore.Brighter; | ||
|
||
namespace Greetings.Ports.Mappers | ||
|
@@ -33,14 +33,14 @@ public class GreetingEventMessageMapper : IAmAMessageMapper<GreetingEvent> | |
public Message MapToMessage(GreetingEvent request) | ||
{ | ||
var header = new MessageHeader(messageId: request.Id, topic: "greeting.event", messageType: MessageType.MT_EVENT); | ||
var body = new MessageBody(JsonConvert.SerializeObject(request)); | ||
var body = new MessageBody(JsonSerializer.Serialize(request, JsonSerialisationOptions.Options)); | ||
var message = new Message(header, body); | ||
return message; | ||
} | ||
|
||
public GreetingEvent MapToRequest(Message message) | ||
{ | ||
var greetingCommand = JsonConvert.DeserializeObject<GreetingEvent>(message.Body.Value); | ||
var greetingCommand = JsonSerializer.Deserialize<GreetingEvent>(message.Body.Value, JsonSerialisationOptions.Options); | ||
|
||
return greetingCommand; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#region Licence | ||
#region Licence | ||
/* The MIT License (MIT) | ||
Copyright © 2014 Ian Cooper <[email protected]> | ||
|
@@ -22,8 +22,8 @@ THE SOFTWARE. */ | |
|
||
#endregion | ||
|
||
using System.Text.Json; | ||
using Greetings.Ports.Events; | ||
using Newtonsoft.Json; | ||
using Paramore.Brighter; | ||
|
||
namespace Greetings.Ports.Mappers | ||
|
@@ -33,14 +33,14 @@ public class GreetingEventMessageMapper : IAmAMessageMapper<GreetingEvent> | |
public Message MapToMessage(GreetingEvent request) | ||
{ | ||
var header = new MessageHeader(messageId: request.Id, topic: "greeting.event", messageType: MessageType.MT_EVENT); | ||
var body = new MessageBody(JsonConvert.SerializeObject(request)); | ||
var body = new MessageBody(JsonSerializer.Serialize(request, JsonSerialisationOptions.Options)); | ||
var message = new Message(header, body); | ||
return message; | ||
} | ||
|
||
public GreetingEvent MapToRequest(Message message) | ||
{ | ||
var greetingCommand = JsonConvert.DeserializeObject<GreetingEvent>(message.Body.Value); | ||
var greetingCommand = JsonSerializer.Deserialize<GreetingEvent>(message.Body.Value, JsonSerialisationOptions.Options); | ||
|
||
return greetingCommand; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.