Escape characters after Serializing using Json

后端 未结 3 664
梦谈多话
梦谈多话 2021-01-27 11:15

Y is my object being serialized in a weird manner while using newtonsoft.json from ASP.Net Web API?

var s = JsonConvert.SerializeObject(request, For         


        
3条回答
  •  鱼传尺愫
    2021-01-27 11:21

    I doubt you are still seeking an answer, but my workaround was to create a JObject with Newtonsoft and pass that.

    Either:

    JObject jBytes = Object.Parse(JsonConvert.SerializeObject(myObject, MyDateTimeFmtString);
    

    or

    JObject jBytes = JObject.FromObject(myObject, MyJsonSerializer);
    

    The first case was my second choice, but I think there is a bug in Newtonsoft where JObject.FromObject ignores the DateFormatString in JsonSerializer.

提交回复
热议问题