Home >Backend Development >C++ >Does Json.NET Cache Serialization Information for Improved Performance?
Overview
In the serialization of the object, check the field and attributes at runtime may be slow. Advanced libraries usually use IL emitting or expression trees to improve performance, but to build IL at runtime, you need to cache to reuse information of similar objects. This leads to the problem of cache strategy used by JSON.NET. Question
When the
method serialize the object of the attribute with json.net, will JSON.NET cache the access information of the members?
Answer JsonConvert.SerializeObject
value
Foo
Yes. Foo
JSON.NET can be serialized in the
class, especially and .
The cache mechanism
IContractResolver
DefaultContractResolver
to maintain a global static example of a cache information. CamelCasePropertyNamesContractResolver
thread security
DefaultContractResolver
CamelCasePropertyNamesContractResolver
Reduce memory consumption
If there is a memory limit, you can create alocal instance, use it for serialization, and then delete the reference to it.
Conclusion
json.net Effectively cache type serialized information to improve the performance during the serialization process, especially when processing large data sets.The above is the detailed content of Does Json.NET Cache Serialization Information for Improved Performance?. For more information, please follow other related articles on the PHP Chinese website!