Skip to content

Commit c544837

Browse files
authored
Double uppercase issue (#1601)
* Addressed double-cap deserializing issue w/ tests * Updated to use predefined cultureInfo property
1 parent 0d42f78 commit c544837

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/RestSharp/Serializers/Json/JsonSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ object Map(object target, IDictionary<string, object> data)
120120
if (!data.TryGetValue(name, out var value))
121121
{
122122
var parts = name.Split('.');
123-
var currentData = data;
123+
IDictionary<string, object> currentData = new Dictionary<string, object>(data, StringComparer.Create(Culture, true));
124124

125125
for (var i = 0; i < parts.Length; ++i)
126126
{

test/RestSharp.Tests/JsonTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,17 @@ public void Can_Deserialize_Lists_of_Simple_Types()
436436
Assert.IsNotEmpty(output.Numbers);
437437
}
438438

439+
[Test]
440+
public void Can_Deserialize_Names_With_Double_Uppercase()
441+
{
442+
var doc = JsonData.CreateJsonWithDoubleUppercase();
443+
var serializer = new JsonSerializer();
444+
var response = new RestResponse { Content = doc };
445+
var p = serializer.Deserialize<PersonForJson>(response);
446+
447+
Assert.AreEqual(435, p.PersonId);
448+
}
449+
439450
[Test]
440451
public void Can_Deserialize_Names_With_Dashes_With_Default_Root()
441452
{

test/RestSharp.Tests/SampleClasses/misc.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public class PersonForJson
127127
public Order Order { get; set; }
128128

129129
public Disposition Disposition { get; set; }
130+
131+
public int PersonId { get; set; }
130132
}
131133

132134
public enum Order { First, Second, Third }

test/RestSharp.Tests/TestData/JsonData.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ public static string CreateJsonWithDashes()
126126
return doc.ToString();
127127
}
128128

129+
public static string CreateJsonWithDoubleUppercase()
130+
{
131+
var doc = new JsonObject
132+
{
133+
["personID"] = 435,
134+
};
135+
return doc.ToString();
136+
}
137+
129138
public static string CreateJson()
130139
{
131140
var doc = new JsonObject

0 commit comments

Comments
 (0)