Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double uppercase issue #1601

Merged
merged 2 commits into from Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RestSharp/Serializers/Json/JsonSerializer.cs
Expand Up @@ -120,7 +120,7 @@ object Map(object target, IDictionary<string, object> data)
if (!data.TryGetValue(name, out var value))
{
var parts = name.Split('.');
var currentData = data;
IDictionary<string, object> currentData = new Dictionary<string, object>(data, StringComparer.Create(Culture, true));

for (var i = 0; i < parts.Length; ++i)
{
Expand Down
11 changes: 11 additions & 0 deletions test/RestSharp.Tests/JsonTests.cs
Expand Up @@ -436,6 +436,17 @@ public void Can_Deserialize_Lists_of_Simple_Types()
Assert.IsNotEmpty(output.Numbers);
}

[Test]
public void Can_Deserialize_Names_With_Double_Uppercase()
{
var doc = JsonData.CreateJsonWithDoubleUppercase();
var serializer = new JsonSerializer();
var response = new RestResponse { Content = doc };
var p = serializer.Deserialize<PersonForJson>(response);

Assert.AreEqual(435, p.PersonId);
}

[Test]
public void Can_Deserialize_Names_With_Dashes_With_Default_Root()
{
Expand Down
2 changes: 2 additions & 0 deletions test/RestSharp.Tests/SampleClasses/misc.cs
Expand Up @@ -127,6 +127,8 @@ public class PersonForJson
public Order Order { get; set; }

public Disposition Disposition { get; set; }

public int PersonId { get; set; }
}

public enum Order { First, Second, Third }
Expand Down
9 changes: 9 additions & 0 deletions test/RestSharp.Tests/TestData/JsonData.cs
Expand Up @@ -126,6 +126,15 @@ public static string CreateJsonWithDashes()
return doc.ToString();
}

public static string CreateJsonWithDoubleUppercase()
{
var doc = new JsonObject
{
["personID"] = 435,
};
return doc.ToString();
}

public static string CreateJson()
{
var doc = new JsonObject
Expand Down