JSON.NET cache sequentialization information to improve performance?
About JSON.NET, the main question is which serialization method it uses and whether the cache is used. For example, will JSON.NET access information for the FOO object cache members and reuse when serialized in the future?
Answer: Yes, it really cached.
class to cache type serialized information. The default contract parser (IContractResolver
and DefaultContractResolver
) maintains this information and reuse it internally, unless the custom contract parser is defined. CamelCasePropertyNamesContractResolver
maintains the static table shared between all instances. DefaultContractResolver
CamelCasePropertyNamesContractResolver
These two contract parsers are safe threads and allow cross -threaded sharing. However, if you create your own contract parser, cache can only occur when cached and reuse the contract parser instance itself.
In the absence of memory use, you can build a local instance of
to reduce the cache contract, use it to serialize, and remove the reference immediately after serialization.
DefaultContractResolver
In the end, the cache type serialization information can improve performance, but excessive cache may occupy memory. By carefully managing the contract parser, a balance between performance and memory consumption can be achieved.
The above is the detailed content of Does Json.NET Cache Serialization Information to Improve Performance?. For more information, please follow other related articles on the PHP Chinese website!