Start process streaming, then object mapping

Jun 28, 2012 at 10:56 AM

I am wondering if the following is possible with JSON.NET. I am currently doing this with Jackson/Java, but need it in .NET/C# replicated.

1)
Read JSON, process streaming, i.e. have callbacks fired on new items (push model) or call functions to read single items (pull model). The latter being preferred.

2)
Upon haved read into the JSON up to a point, parse/map another item in the JSON into an object of some class, where the class is determined based on the initial JSON read (in streaming mode)

=====

Here is an example:

[345, {a: "foo", b: "bar"}]

Would need to be processed like this:
Begin streaming read, recognize JSON array, read 345.
Lookup the class of ID 345, lets say "class Foobar"
Parse the 2nd array item (the dict) into an object of class Foobar => object mapping mode
Read the end/rest of the JSON (the close of array) in streaming mode.

=====

Is that possible? Any samples / code snippets what to do?

Thanks alot,

Tobias