Default camel case of property names in JSON serialization

后端 未结 7 972
感情败类
感情败类 2020-12-14 00:35

I have a bunch of classes that will be serialized to JSON at some point and for the sake of following both C# conventions on the back-end and JavaScript conventions on the f

相关标签:
7条回答
  • 2020-12-14 01:15

    When serializing your object, pass in some custom settings.

    var settings = new JsonSerializerSettings
    {
        ContractResolver = new CamelCasePropertyNamesContractResolver()
    };
    
    var json = JsonConvert.SerializeObject(yourObject, settings);
    
    0 讨论(0)
提交回复
热议问题