diff --git a/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs b/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs
index fd0eb397..bdc8e7e6 100644
--- a/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Utilities/StringUtilsTests.cs
@@ -64,6 +64,10 @@ namespace Newtonsoft.Json.Tests.Utilities
Assert.AreEqual("snA__kEcAsE", StringUtils.ToCamelCase("SnA__kEcAsE"));
Assert.AreEqual("snA__ kEcAsE", StringUtils.ToCamelCase("SnA__ kEcAsE"));
Assert.AreEqual("already_snake_case_ ", StringUtils.ToCamelCase("already_snake_case_ "));
+ Assert.AreEqual("isJSONProperty", StringUtils.ToCamelCase("IsJSONProperty"));
+ Assert.AreEqual("shoutinG_CASE", StringUtils.ToCamelCase("SHOUTING_CASE"));
+ Assert.AreEqual("9999-12-31T23:59:59.9999999Z", StringUtils.ToCamelCase("9999-12-31T23:59:59.9999999Z"));
+ Assert.AreEqual("hi!! This is text. Time to test.", StringUtils.ToCamelCase("Hi!! This is text. Time to test."));
}
[Test]
@@ -89,6 +93,10 @@ namespace Newtonsoft.Json.Tests.Utilities
Assert.AreEqual("sn_a__k_ec_as_e", StringUtils.ToSnakeCase("SnA__kEcAsE"));
Assert.AreEqual("sn_a__k_ec_as_e", StringUtils.ToSnakeCase("SnA__ kEcAsE"));
Assert.AreEqual("already_snake_case_", StringUtils.ToSnakeCase("already_snake_case_ "));
+ Assert.AreEqual("is_json_property", StringUtils.ToSnakeCase("IsJSONProperty"));
+ Assert.AreEqual("shouting_case", StringUtils.ToSnakeCase("SHOUTING_CASE"));
+ Assert.AreEqual("9999-12-31_t23:59:59.9999999_z", StringUtils.ToSnakeCase("9999-12-31T23:59:59.9999999Z"));
+ Assert.AreEqual("hi!!_this_is_text._time_to_test.", StringUtils.ToSnakeCase("Hi!! This is text. Time to test."));
}
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/JsonContainerAttribute.cs b/Src/Newtonsoft.Json/JsonContainerAttribute.cs
index 1deab53a..32bd975e 100644
--- a/Src/Newtonsoft.Json/JsonContainerAttribute.cs
+++ b/Src/Newtonsoft.Json/JsonContainerAttribute.cs
@@ -53,7 +53,7 @@ namespace Newtonsoft.Json
public string Description { get; set; }
///
- /// Gets the collection's items converter.
+ /// Gets or sets the collection's items converter.
///
/// The collection's items converter.
public Type ItemConverterType { get; set; }
@@ -70,7 +70,7 @@ namespace Newtonsoft.Json
public object[] ItemConverterParameters { get; set; }
///
- /// Gets the of the .
+ /// Gets or sets the of the .
///
/// The of the .
public Type NamingStrategyType
diff --git a/Src/Newtonsoft.Json/JsonPropertyAttribute.cs b/Src/Newtonsoft.Json/JsonPropertyAttribute.cs
index c9d2dae3..0252ee44 100644
--- a/Src/Newtonsoft.Json/JsonPropertyAttribute.cs
+++ b/Src/Newtonsoft.Json/JsonPropertyAttribute.cs
@@ -66,7 +66,7 @@ namespace Newtonsoft.Json
public object[] ItemConverterParameters { get; set; }
///
- /// Gets the of the .
+ /// Gets or sets the of the .
///
/// The of the .
public Type NamingStrategyType { get; set; }
diff --git a/Src/Newtonsoft.Json/Serialization/NamingStrategy.cs b/Src/Newtonsoft.Json/Serialization/NamingStrategy.cs
index 7c77b421..cf957af3 100644
--- a/Src/Newtonsoft.Json/Serialization/NamingStrategy.cs
+++ b/Src/Newtonsoft.Json/Serialization/NamingStrategy.cs
@@ -23,7 +23,7 @@
///
/// The initial property name.
/// A flag indicating whether the property has had a name explicitly specfied.
- /// A property name.
+ /// The serialized property name.
public virtual string GetPropertyName(string name, bool hasSpecifiedName)
{
if (hasSpecifiedName && !OverrideSpecifiedNames)
@@ -38,7 +38,7 @@
/// Gets the serialized key for a given dictionary key.
///
/// The initial dictionary key.
- /// A dictionary key.
+ /// The serialized dictionary key.
public virtual string GetDictionaryKey(string key)
{
if (!ProcessDictionaryKeys)
diff --git a/Src/Newtonsoft.Json/Utilities/StringUtils.cs b/Src/Newtonsoft.Json/Utilities/StringUtils.cs
index d166b6ec..84e722e9 100644
--- a/Src/Newtonsoft.Json/Utilities/StringUtils.cs
+++ b/Src/Newtonsoft.Json/Utilities/StringUtils.cs
@@ -213,9 +213,13 @@ namespace Newtonsoft.Json.Utilities
{
case SnakeCaseState.Upper:
bool hasNext = (i + 1 < s.Length);
- if (i > 0 && hasNext && !char.IsUpper(s[i + 1]))
+ if (i > 0 && hasNext)
{
- sb.Append('_');
+ char nextChar = s[i + 1];
+ if (!char.IsUpper(nextChar) && nextChar != '_')
+ {
+ sb.Append('_');
+ }
}
break;
case SnakeCaseState.Lower: