I need to deserialize from a JSON StreamReader
, without instantiating intermediate objects for every object in that stream.
- JSON.NET invoked like
JsonConvert.DeserializeObject<T>(string json, JsonConverter[] converters)
- doesn't accept
StreamReader
, and - creates in memory the whole set of
Newtonsoft.Json.*
classes for the JSON structore, as memory profiler shows. _I'm not actually sure this is the case, because myJsonConverter
s _
- doesn't accept
- JavaScriptSerializer also doesn't seem to support
Stream
s at all.- And even undocummented
new JsonSerializer().Deserialize(new JsonTextReader(streamReader))
- And even undocummented
What I want in a zero approach is a SAX or StAX-style JSON parser.
What I want ideally, is an API like
object JsonCooler.DeserializeObject<T>(
StreamReader jsonStream, Converter[] converters)
which will deserialize directly into a new instance of class T
, not keeping all of its intermediate DOM-like objects in memory.
Does such a deserializer exist? Or what am I missing at the concept level?