title: Deserialize multiple objects from stream by json.net
body: <p>Greatings! I need to deserialize a file of different objects serialized as json. Here is the resulting file:</p>
  
  <pre><code>{
    "Number": 1,
    "Description": "Run version with strategy data",
    "Context": "NA"
  }[
    {
      "N": 0.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.0,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 1.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.2999999523162842,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 2.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.0,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 3.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.2999999523162842,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 4.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.0,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 5.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.2999999523162842,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 6.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.0,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 7.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.2999999523162842,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 8.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.0,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    },
    {
      "N": 9.0,
      "T": 2.0,
      "Adc": [
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0
      ],
      "SpltFr": 2.2999999523162842,
      "Acc": 1.0,
      "DAcc": 0.0,
      "Acc2": 1.0,
      "OscFr": 0.5,
      "Fltr": 0,
      "CmpEr": false,
      "ErrPck": 0,
      "IndxDiff": 0,
      "Pos": 0,
      "FastAcc": [],
      "GIndx": 0,
      "Indx": 0,
      "PcTime": "0001-01-01T00:00:00"
    }
  ]
  </code></pre>
  
  <p>I'm using json.net but that seem that it's doesn't work as I want it to.</p>
  
  <pre><code>StreamReader reader = new StreamReader(fileName, Encoding.GetEncoding(1251));
  var serializer = new JsonSerializer() { CheckAdditionalContent = false };
  var obj1 = serializer.Deserialize(reader, typeof(Type1));
  var obj2 = serializer.Deserialize(reader, typeof(Type2));
  </code></pre>
  
  <p>This code reads only the first object and throws exeption while reading the second. What do I do wrong? Can the json.net even fulfill my task? Thanks in advance!</p>
  
  <p>Taking some advices from this topic in account I've modified my code into this:</p>
  
  <pre><code>using (FileStream fs = File.Open(fileName, FileMode.Open))
  using (StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(1251)))
  using (JsonTextReader jr = new JsonTextReader(sr))
  {
  
       JsonSerializer serializer = new JsonSerializer()
       {
              Formatting = Newtonsoft.Json.Formatting.Indented,
              CheckAdditionalContent = false,
              TypeNameHandling = TypeNameHandling.Auto
  
       };
       var data1 = serializer.Deserialize(jr, typeof(Type1));
  
       var data2 = serializer.Deserialize(jr, typeof(List&lt;Type2&gt;));
  }
  </code></pre>
  
  <p>But it still doesn't work properly. Seems that after reading the first object my cursor doesn't stop immediately at the end of it but somewhere in the second object. Therefore my reader can't read any objects any more.</p>