I'm trying to serialize a dictionary within a class and the keys inside the CustomAttributes
dictionary are getting formatted even though I've provided the ProcessDictionaryKeys
parameter as false.
I've added [JsonProperty]
as shown below:
[JsonProperty(NamingStrategyType = typeof(SnakeCaseNamingStrategy), NamingStrategyParameters = new object[] { false, false })]
public IDictionary<string, string> CustomAttributes { get; set; }
my CustomAttributes data looks like this:
CustomAttributes = new Dictionary<string, string>()
{
{"Custom Attribute 1", "1"},
{"CustomAttribute 2", "2"}
}
and the JSON which is produced looks like:
custom_attributes":{"custom Attribute 1":"1","customAttribute 2":"2"
As you can see, the first letter of each of the dictionary keys are being uncapitalised. How can I stop this from happening?
EDIT: Changing the ProcessDictionaryKeys
parameter to true doesn't seem to make any difference.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…