-CamelCasePropertyNamesContractResolver now updates dictionary and dynamic property names

This commit is contained in:
JamesNK
2011-03-21 08:06:12 +00:00
parent 71446e9772
commit 9e1c9e96fb
6 changed files with 75 additions and 1 deletions
@@ -167,6 +167,50 @@ namespace Newtonsoft.Json.Tests.Serialization
""Medium"",
""Large""
]
}", json);
}
#if !(NET35 || NET20 || WINDOWS_PHONE)
[Test]
public void DynamicCamelCasePropertyNames()
{
dynamic o = new DynamicTests.TestDynamicObject();
o.Text = "Text!";
o.Integer = int.MaxValue;
string json = JsonConvert.SerializeObject(o, Formatting.Indented,
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
Assert.AreEqual(@"{
""text"": ""Text!"",
""integer"": 2147483647,
""int"": 0,
""childObject"": null
}", json);
}
#endif
[Test]
public void DictionaryCamelCasePropertyNames()
{
Dictionary<string, string> values = new Dictionary<string, string>
{
{"First", "Value1!"},
{"Second", "Value2!"}
};
string json = JsonConvert.SerializeObject(values, Formatting.Indented,
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
Assert.AreEqual(@"{
""first"": ""Value1!"",
""second"": ""Value2!""
}", json);
}
}