title: Token StartObject in state ObjectStart would result in an invalid JSON object. Path ''."
body: <p>I have this JSON</p>
  
  <pre><code> {
  name: 'Dashboard',
  url: '/Home',
  icon: 'icon-speedometer',
   },
   {
  name: 'Reports',
  url: '/Reports/GenerateReport',
  icon: 'icon-calculator'
   },
   {
   name: 'Administration',
   url: '/adminstration',
   icon: 'icon-shield',
   children: [
    {
      name: 'Templates',
      url: '/Templates/TemplatesList',
      // icon: 'icon-settings'
    },
    {
      name: 'Rules',
      url: '/Rules/RulesList',
      // icon: 'icon-equalizer'
    },
    {
      name: 'Products',
      url: '/Products/ProductsList',
      // icon: 'icon-grid'
    },
    {
      name: 'Users',
      url: '/Users/UsersList'
    },
    {
      name: 'Clients',
      url: '/Clients/ClientsList'
    }
  </code></pre>
  
  <p>and in C# here's the model for mapping it</p>
  
  <pre><code>public class ParsedAccessPage
  {
      public int Id { get; set; }
      public string name { get; set; }
      public string url { get; set; }
      public string icon { get; set; }
      public List&lt;ParsedAccessPageChild&gt; children { get; set; }
  }
  
  public class ParsedAccessPageChild
  {
      public int Id { get; set; }
      public string name { get; set; }
      public string url { get; set; }
      public int ParentId { get; set; }
  }
  </code></pre>
  
  <p>and this function to parse the model to JSON</p>
  
  <pre><code>        StringBuilder sb = new StringBuilder();
          JsonWriter jw = new JsonTextWriter(new StringWriter(sb));
          jw.Formatting = Formatting.Indented;
          jw.WriteStartObject();
          foreach (var page in parsedAccessPage)
          {
              jw.WriteStartObject();
              jw.WritePropertyName("name");
              jw.WriteValue(page.name);
              jw.WritePropertyName("url");
              jw.WriteValue(page.url);
              jw.WritePropertyName("icon");
              jw.WriteValue(page.icon);
              if (page.children.Count &gt; 0)
              {
                  jw.WritePropertyName("children");
                  jw.WriteStartObject();
                  foreach (var child in page.children)
                  {
                      jw.WritePropertyName("name");
                      jw.WriteValue(child.name);
                      jw.WritePropertyName("url");
                      jw.WriteValue(child.url);
                      //jw.WriteEndArray();
                  }
                  jw.WriteEndObject();
  
              }
              jw.WriteEndObject();
              //jw.WriteEndArray();
  
          }
          jw.WriteEndObject();
          return sb.ToString();
  </code></pre>
  
  <p>I keep getting this error: </p>
  
  <p>"Token StartObject in state ObjectStart would result in an invalid JSON object. Path ''."</p>
  
  <p>I'm not sure why the 1st line in the 1st foreach keeps throwing it ... I'm trying to make the json appear as the model.</p>