ASP.NET default json serializer is slow, and I need a lot of performance, so I want to use ServiceStack.Text Serializer , is there a way I can use that serializer instead of the one by default?
If I send a JSON request to my ASMX file, and return an object it will serialize it using Microsoft's slow implementation.
I guess I could always return a string, and serialize manually, but I just want to know if it's possible.
Check out this link: http://msdn.microsoft.com/library/bb763183%28v=vs.100%29.aspx
Basically you need to put your custom converter in configuration tag on web.config:
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50">
<converters>
<add name="MyCustomConverter"
type="MyCompany.ConvertersNameSpace.MyTypeConverter"/>
</converters>
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
Since JavascriptSerializer needs to inform which classes are supported, i think asp.net will assume your serializer instead of default serializer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.