title: Errors parsing JSON using Newtonsoft.Json
body: <p>I am getting the following error when I try and parse my JSON using Newtonsoft.Json using</p>
  
  <pre><code>Response result = JsonConvert.DeserializeObject&lt;Response&gt;(unfilteredJSONData);
  </code></pre>
  
  <blockquote>
    <p>Can not add property string to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.</p>
  </blockquote>
  
  <p>I have no control over the JSON feed and they just added <code>flags1</code> and <code>flags2</code>. The duplicate string seems to be causing the error, but I don't have any good idea on how to resolve it.  This code was working well until the addition of the new fields.</p>
  
  <p><strong>Update:</strong></p>
  
  <hr>
  
  <p>The first error was caused by using an outdated version of JSON.net. There was a built-in version with the CMS system I am using and it was 3.5. When I use 4.5 I get a new error:</p>
  
  <blockquote>
    <p>Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject.</p>
  </blockquote>
  
  <p>It turns out my JSON below was not exactly the same format as what I am dealing with. Please note the update. The error seems to be caused here:</p>
  
  <pre><code>"flags1": {
      "string": "text",
      "string": "text"
  },
  </code></pre>
  
  <p>The JSON is:</p>
  
  <pre><code>{
      "result":
      {
          "lookups":
          [
              {
                  "groups":
                  [
                      {
                          "item0": "text",
                          "item1": "text",
                          "item2": 0,
                          "item3": 0,
                          "item4": 11.5,
                          "item5": true
                      },
                      {
                          "item6": "text",
                          "oddName": "text"
                      },
                      {
                          "item7": {
                              "subitem0": "text",
                              "subitem1": 0,
                              "subitem2": true
                          },
                          "item8": {
                              "subitem0": "string",
                              "subitem1": 0,
                              "subitem2": true
                          }
                      },
                      {
                          "url": "http://google.com",
                          "otherurl": "http://yahoo.com",
                          "alturllist": [],
                          "altotherurl": []
                      },
                      {},
                      {
                          "flags1": {
                              "string": "text"
                          },
                          "flags2": {
                              "string": "text"
                          }
                      }
                  ]
              },
              {
                  "groups":
                  [
                      {
                          "item0": "text",
                          "item1": "text",
                          "item2": 0,
                          "item3": 0,
                          "item4": 11.5,
                          "item5": true
                      },
                      {
                          "item6": "text",
                          "oddName": "text"
                      },
                      {
                          "item7": {
                              "subitem0": "text",
                              "subitem1": 0,
                              "subitem2": true
                          },
                          "item8": {
                              "subitem0": "string",
                              "subitem1": 0,
                              "subitem2": true
                          }
                      },
                      {
                          "url": "http://google.com",
                          "otherurl": "http://yahoo.com",
                          "alturllist": [],
                          "altotherurl": []
                      },
                      {},
                      {
                          "flags1": {
                              "string": "text",
                              "string": "text"
                          },
                          "flags2": {}
                      }
                  ]
              }
          ]
      }
  }
  </code></pre>
  
  <p>The C# classes are:</p>
  
  <pre><code>// response
  [DataContract]
  public class Response
  {
      [DataMember(Name = "result")]
      public Result result { get; set; }
  }
  [DataContract]
  public class Result
  {
      [DataMember(Name = "lookups")]
      public List&lt;Item&gt; lookups { get; set; }
  }
  [DataContract]
  public class Item
  {
      [DataMember(Name = "groups")]
      public List&lt;Dictionary&lt;string, object&gt;&gt; groups { get; set; }
  }
  </code></pre>
  
  <p>I have simplified the JSON and code example for clarity.</p>
  
  <p>I included the code aspx to simplify reproducing.</p>
  
  <p>test.aspx</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
      &lt;code&gt;
      &lt;%=response %&gt;
      &lt;/code&gt;&lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>test.aspx.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Runtime.Serialization;
  
  using Newtonsoft.Json;
  using Newtonsoft.Json.Linq;
  
  using NLog;
  
  public partial class Test : System.Web.UI.Page
  {
      public string response = string.Empty;
      public static string cacheDirPath = HttpRuntime.AppDomainAppPath + "cache\\";
      private static Logger log = LogManager.GetLogger("productFeed");
  
      protected void Page_Load(object sender, EventArgs e)
      {
  
          response = readDataFromFile(cacheDirPath + "test2.json");
          Response masheryResult = JsonConvert.DeserializeObject&lt;Response&gt;(response);
      }
      private string readDataFromFile(string filePath)
      {
          string JSONData = string.Empty;
          try
          {
              StreamReader myFile = new StreamReader(filePath);
  
              JSONData = myFile.ReadToEnd();
  
              myFile.Close();
          }
          catch (Exception e)
          {
              log.Warn(e.Message);
          }
  
          return JSONData;
      }
  }
  
  // response
  [DataContract]
  public class Response
  {
      [DataMember(Name = "result")]
      public Result result { get; set; }
  }
  [DataContract]
  public class Result
  {
      [DataMember(Name = "lookups")]
      public List&lt;Item&gt; lookups { get; set; }
  }
  [DataContract]
  public class Item
  {
      [DataMember(Name = "groups")]
      public List&lt;Dictionary&lt;string, object&gt;&gt; groups { get; set; }
  }
  </code></pre>