diff --git a/README.md b/README.md index 7050b8a4c..082412b6e 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,21 @@ if (result.IsFailure) } ``` +- When calling `channel.Publish` with a dotnet object instance as the message data, the library will use the Newtonsoft Json.NET library to serialize the message with default serialization settings. +- If you need to use custom seralization settings, you can apply the serialization yourself and send the resulting string as the message data: + +```csharp +var serializedData = JsonConvert.SerializeObject(message, + new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + }); + +var ablyMessage = new Message("name", serializedData) {Encoding = "json"}; + +channel.Publish(ablyMessage); +``` + ### Getting channel history Calling history returns a paginated list of message. The object is of type `PaginatedResult` and can be iterated through as a normal list. @@ -331,6 +346,22 @@ catch(AblyException ablyError) } ``` +- When calling `channel.PublishAsync` with a dotnet object instance as the message data, the library will use the Newtonsoft Json.NET library to serialize the message with default serialization settings. +- If you need to use custom seralization settings, you can apply the serialization yourself and send the resulting string as the message data: + +```csharp +var serializedData = JsonConvert.SerializeObject(message, + new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + }); + +var ablyMessage = new Message("name", serializedData) {Encoding = "json"}; + +channel.Publish(ablyMessage); +``` + + ### Querying channel history ```csharp