Json.NET version 10 added support to async serialization.
Version 11 added support to generic JsonConverter<T>
.
The problem is that JsonConverter<T>
and previous JsonConverter
only support synchronous methods.
i.e.: public override void WriteJson(...)
The JsonWriter
passed to WriterJson
supports both synchronous and asynchronous methods like:
writer.WritePropertyNameAsync()
and writer.WritePropertyName()
But since WriteJson
itself is synchronous, the async option is not usable here.
Is it possible to have a custom JsonConverter
with async methods?
JsonConvert.SerializeAsync
here: github.com/JamesNK/Newtonsoft.Json/issues/1193 – MohnJToken.FromObject
, but since you don't want to hold whole object in memory also - I see no way with current api indeed. – Mohn