Custom serialization converters for WCF service

We are currently using the .asmx web service method, which serializes our object in Json to be returned to the client and is consumed by MS Ajax code. For some members of the object, we use custom converters through classes that are derived from the JavaScriptConverter and override the Serialize method. We "plug" these custom converters in our web.config through the elements:

<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="2000000">
        <converters>
          <add name="ElementReference" type="OurNamespace.OurJavascriptConverter">

Now we go to the WCF web service. I can not find the equivalent of WCF.

Thanks for any help.

+3
source share
3 answers

WCF, JSON.NET.

JSON.NET , WCF JSON.

+3

WCF DataContractSerializer basic-http NetDataContractSerializer tcp. /, , "" ( ). , , , "mex" .

. .

AFAIK, the most likely alternative (for custom serialization) would be to implement IXmlSerializableand do everything yourself - not fun.

0
source

Source: https://habr.com/ru/post/1707425/


All Articles