Closed MarcusKohnert closed 5 years ago
needs to be in the same format as specified by IOptions
(DateParseHandling).
You should be able to construct a JsonSerailizer
using MvcJsonOptions.SerializerSettings
without much ceremony - in fact that's what the policy does:
https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNetCore.Mvc.Formatters.Json/Internal/JsonSerializerObjectPolicy.cs#L27.
If you do need to pool your JsonSerializer
settings, I'd recommend just copying the type. The fact that the formatter pools the serializer, is an implementation detail and we wouldn't expose it as part of a public API surface.
Description of the problem: #8689
We are using
Microsoft.AspNetCore.Mvc.Formatters.Json.Internal.JsonSerializerObjectPolicy
because we want to get hold of aJsonSerializer
from theObjectPool
.Use case:
We retrieve a Json-String from a DB and want to serialize it to the client as a string property on an object. But the to-string-serialized-json needs to be in the same format as specified by
IOptions<MvcJsonOptions>
(DateParseHandling).Exact code:
SomeRepresentation.cs
SomeController.cs - in an action method