Ensuring json keys are lowercase in .NET

后端 未结 5 2062
生来不讨喜
生来不讨喜 2020-11-28 02:25

Is there simple way using JSON in .NET to ensure that the keys are sent as lower case?

At the moment I\'m using the newtonsoft\'s Json.NET library and simply using

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 03:16

    For me I used a combination of some of the other answers and ended up with this

            return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });
    

    was closer to a solution to what I was looking for as I was not looking to create my own

提交回复
热议问题