title: Newtonsoft.Json - Getting corresponding line numbers of deserialized objects from JSON for better error handling
body: <p>My application accepts long JSON templates from clients that I deserialize and process. I would like to provide better error handling information that contains lineNumber of invalid objects in the JSON text to customers. Note that this is for errors that occur in post-processing and <em>NOT</em> for errors that occur during deserialization as this is already handled by the Newtonsoft.</p>
  
  <p>As an example, I have the below JSON and its corresponding .Net type</p>
  
  <pre><code>{
      "Version": "1.0.0.0",                        
      "MyComplexObject": [
      {
          "Prop1": "Val1",
          "Prop2": "Val2",
          "Prop3": 1
      }
      ]
  }
  
  public class MyComplexObject
  {
      [JsonProperty]
      public string Prop1 { get; set; }
  
      [JsonProperty]
      public string Prop2 { get; set; }
  
      [JsonProperty]
      public int Prop3 { get; set; }
  
      **public int LineNumber;
      public int LinePosition;**
  }
  
  public class RootObject
  {
      [JsonProperty]
      public string Version { get; set; }
  
      [JsonProperty]
      public List&lt;MyComplexObject&gt; MyComplexObject { get; set; }
  }
  </code></pre>
  
  <p>I would like the LineNumber and LinePosition properties to be populated at deserialization so that it may be used at a later time. I am currently deserializing the JSON using the below code</p>
  
  <pre><code>JsonConvert.DeserializeObject&lt;RootObject&gt;(value: rawJson,settings: mysettings);
  </code></pre>
  
  <p>Appreciate any responses</p>