Skip to content

Commit a0b0ab2

Browse files
author
Ruben Bisharyan
committed
Fix Deserialization with new CamelCaseJsonSerializerOption
1 parent fbaa86d commit a0b0ab2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Communicator/Communicator.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>2.1.0</Version>
11+
<Version>2.1.1</Version>
1212
<PackageId>Pandatech.Communicator</PackageId>
1313
<Title>SMS and Email Communication helper</Title>
1414
<PackageTags>Pandatech, library, Sms, Email, Messages</PackageTags>
1515
<Description>A versatile .NET library for integrating SMS and email functionalities. Supports multiple SMS providers and easy configuration through appsettings.json or web builders, ideal for efficient and reliable messaging in any application..</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-communicator</RepositoryUrl>
17-
<PackageReleaseNotes>Newton soft removal</PackageReleaseNotes>
17+
<PackageReleaseNotes>Fixed Deserialization with CamelCase</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

src/Communicator/Services/Implementations/SmsService.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ internal class SmsService(CommunicatorOptions options, IHttpClientFactory httpCl
1919
{
2020
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
2121
};
22+
private static JsonSerializerOptions CamelCaseJsonSerializerOption =>
23+
new()
24+
{
25+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
26+
};
2227

2328
private string _channel = null!;
2429
private HttpClient _httpClient = null!;
@@ -147,7 +152,7 @@ private async Task<List<GeneralSmsResponse>> SendSmsViaDexatelAsync(SmsMessage s
147152
var responseContent = await response.Content.ReadAsStringAsync(cancellationToken);
148153

149154
var responseObject =
150-
JsonSerializer.Deserialize<DexatelSmsSendResponse>(responseContent, SnakeCaseJsonSerializerOption);
155+
JsonSerializer.Deserialize<DexatelSmsSendResponse>(responseContent, CamelCaseJsonSerializerOption);
151156

152157
return responseObject?.Data
153158
.Select(x =>
@@ -188,7 +193,7 @@ private async Task<List<GeneralSmsResponse>> SendSmsViaTwilioAsync(SmsMessage sm
188193
var responseContent = await response.Content.ReadAsStringAsync(cancellationToken);
189194

190195
var responseObject =
191-
JsonSerializer.Deserialize<TwilioSmsSendResponse>(responseContent, SnakeCaseJsonSerializerOption);
196+
JsonSerializer.Deserialize<TwilioSmsSendResponse>(responseContent, CamelCaseJsonSerializerOption);
192197

193198
result.Add(responseObject ?? new TwilioSmsSendResponse());
194199
}

0 commit comments

Comments
 (0)