We made a change back in 0.22.0 I think it was, to make the default serializer camelCase by default.
The JSON.NET one is pascal case by default, I think we should force it to be camelCase by default and allow the user to orderride this.
Currently to achieve camelCasing we have to do:
public class CustomJsonSerializer : JsonSerializer
{
public CustomJsonSerializer()
{
this.ContractResolver = new CamelCasePropertyNamesContractResolver();
}
}
And register the type.
People should be doing this to disable camelCasing.
Thoughts?
+100 for camelCasing by default.
+100 from me as well :grin:
I think all serializers should follow the static JsonSettings.RetainCasing
(and JsonSettings.ISO8601DateFormat
as well). IMO it would be nice to also change the name of RetainCasing
to CamelCalse
, e.g. by adding another property and calling into it from RetainCasing
:
[Obsolete("This name is ambiguous, and the property will be removed in a future version. Use CamelCase instead.")]
public static bool RetainCasing
{
get { return !CamelCase; }
set { CamelCase = !value; }
}
public static bool CamelCase { get; set; }
:+1: for camelCasing and ISO8601DateFormat by default too.
:+1:
:shipit: :shipit: :shipit:
:+1:
I agree, and particularly with what @khellang has said. Just spent and hour or so with @PureKrome tracking down why stuff wasn't being camelCased when we both thought it was the default (but didn't realise this didn't extend to Json.Net). RetainCasing set to false behaves differently between default and Json.Net, I reckon this is tripping point, would prefer to see the behaviour the same, but overridable, via the RetainCasing (or more preferably CamelCasing) static setting.
I'm in the middle of fixing 1 of 4 things I need to fix for Nancy to stop all you guys (@purekrome) whinging.
If someone else wants to pick this up they can. The consensus is that we should fix it.
I agree with @khellang that the setting should be 1 place for all JSON serializers.
Most helpful comment
+100 from me as well :grin: