Change default date serialization in WCF

前端 未结 5 739
-上瘾入骨i
-上瘾入骨i 2020-12-03 07:39

Is there anyway to change the default JSON serialization/deserialization of DateTime in WCF?

Currently, DateTime are serialized into the /Date(1372252162657+0

5条回答
  •  自闭症患者
    2020-12-03 08:27

    One way is to use a message formatter to change the default DataContractSerializer as described in WCF Extensibility – Message Formatters.

    Another option is to write an extension method that loads your object into a stream and then you can apply whatever serializer you want to the object. See the accepted answer for Replace default JSON serializer in WCF 4 to JSON.NET for details on how to do this.

提交回复
热议问题