It seems that, when using JsonExtensionData on a parent class, the child class's additional attributes are not converted to camel case. The shared ones are.
It seems like maybe the camel case isn't being applied to the extended data dictionary keys?
So returning a base enumeration I get something like the following
ParentClass {
Id;
SharedField;
[JsonExtensionData]
Dictionary<string, JToken> _extendedData;
}
SubClass extends ParentClass {
AdditionalField;
}
"subClass": {
"id": 1,
"sharedField": "somevalue",
"AdditionalField": "somevalue"
}
whereas I would expect
"subClass": {
"id": 1,
"sharedField": "somevalue",
"additionalField": "somevalue"
}
One more linked: Names of properties from JsonExtensionData dictionay are serialized not in Camel Case while JsonSerializerSettings.ContractResolver is CamelCasePropertyNamesContractResolver
For example,
class Person
{
public String Name { get; set; }
[JsonExtensionData]
public Dictionary<String, JToken> AdditionalProperties { get; set; }
}
var person = new Person
{
Name = "John",
AdditionalProperties = new Dictionary<String, JToken> {{"FormOfAddress", "Mr"}}
};
var serializerSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
};
var personJson = JsonConvert.SerializeObject(person, serializerSettings);
Console.WriteLine(personJson);
And in output I have
{"name":"John","FormOfAddress":"Mr"}
But expected
{"name":"John","formOfAddress":"Mr"}
I am having a similar issue.
I got the same problem today and don't have to open an issue for it :)
@JamesNK when will this be released ? or is there any nightly releases for this project ?
@JamesNK im using version 9.0.1 and i still have a problem, related issue https://github.com/JamesNK/Newtonsoft.Json/issues/868
[JsonExtensionData]
public Dictionary<string, object> Values { get; set; }
in this i have properties named TestCar1 = "anyvalue", TestCar2="val2val"
and i serialize it like this:
var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
var json = JsonConvert.SerializeObject(data, Formatting.Indented, jsonSerializerSettings);
however thay dont get camel cased.
Because it isn't released yet. No I don't have a date for you.
@JamesNK this is still not released from 2 years ago? Because it looks like this is still a bug

For anyone else struggling with this, I can save you a few hours :).
Make sure you're setting ProcessExtensionDataNames to true in your NamingStrategy
e.g.
var formatter = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
ProcessExtensionDataNames = true
}
}
};
@brianwebb I've had that enabled the whole time; doesnt actually fix it
@onionhammer I think the issue you're seeing is because of this line:
var obj = JsonConvert.DeserializeObject<Data>(data);
Have a look here - https://stackoverflow.com/questions/35777561/get-a-dynamic-object-for-jsonconvert-deserializeobject-making-properties-upperca/35784914#35784914
Fiddle showing the issue here - https://dotnetfiddle.net/Jr90D2
Deserialising a nested object creates a JToken heirarchy rather than a dynamic object. This means that it will keep the original tag name - in your case "Toes" with a capital T.
Most helpful comment
One more linked: Names of properties from JsonExtensionData dictionay are serialized not in Camel Case while JsonSerializerSettings.ContractResolver is CamelCasePropertyNamesContractResolver
For example,
And in output I have
{"name":"John","FormOfAddress":"Mr"}But expected
{"name":"John","formOfAddress":"Mr"}