Closed kikaragyozov closed 4 years ago
The latter will scale better as content gets larger as you can avoid buffering the entire object in memory first.
@davidfowl Thank you for answering! Is it okay then to use JsonSerializer.Serialize(Object, Type, JsonSerializerOptions)
to avoid all of the above streams and what-not in order to create my json string? I'm not sure if that's done in an utf-8 way. The only method that seems to do utf-8 json conversion requires usage of streams?
Everything on the JSONSerializer is Utf8 only.
Is the above the correct way to do it for UTF8 json content? The
JsonOptions
passed are the default ones used in an ASP.NET Core 3.1 application.Alternatively, from IdentityServer's library, do we just do the following:
I'm not sure which is the more correct way, and which yields the same performance as when ASP.NET Core itself does the heavy lifting (serialization).
How is it being done there? Is it using streams like here, or something else entirely? My goal is to do the same heavy-lifting ASP.NET Core 3.1 originally does for serialization of objects.
Thank you.