title: Deserialize a JObject to a list of .NET objects
body: <p>The task I have is to parse JSON into objects which can then create a form. This form can have sub-forms within it and it is this step I am having difficulty with.
  Consider this JObject which is a representation of the sub-form and, because the main form has already been deserialized, is now passed as a JObject:</p>
  
  <pre><code>  {
    "3705": {
      "type": "radioGroup",
      "label": "Loft Insulation Applicable",
      "default_value": null,
      "order": "2",
      "required": "false",
      "security": "false",
      "option": null,
      "child": [
        {
          "type": "radio",
          "label": "No",
          "order": "3"
        },
        {
          "type": "radio",
          "label": "Yes",
          "order": "4"
        }
      ]
    },
    "3708": {
      "type": "input",
      "label": "Existing Depth (mm)",
      "default_value": null,
      "order": "5",
      "required": "false",
      "security": "false",
      "option": null
    },
    "3709": {
      "type": "input",
      "label": "Required Depth (mm)",
      "default_value": null,
      "order": "6",
      "required": "false",
      "security": "false",
      "option": null
    },
    "3715": {
      "type": "radioGroup",
      "label": "Total Pipework Meterage",
      "default_value": null,
      "order": "16",
      "required": "false",
      "security": "false",
      "option": null,
      "child": [
        {
          "type": "radio",
          "label": "15 mm",
          "order": "17"
        },
        {
          "type": "radio",
          "label": "22 mm",
          "order": "18"
        },
        {
          "type": "radio",
          "label": "28 mm",
          "order": "19"
        }
      ]
    },
    "3719": {
      "type": "formLabel",
      "label": "Loft Access Requirements",
      "default_value": null,
      "order": "20",
      "required": "false",
      "security": "false",
      "option": null
    },
    "3720": {
      "type": "radioGroup",
      "label": "Crawlers",
      "default_value": null,
      "order": "21",
      "required": "false",
      "security": "false",
      "option": null,
      "child": [
        {
          "type": "radio",
          "label": "No",
          "order": "22"
        },
        {
          "type": "radio",
          "label": "Yes",
          "order": "23"
        }
      ]
    },
    "3723": {
      "type": "radioGroup",
      "label": "Cavity Ladders for Loft",
      "default_value": null,
      "order": "24",
      "required": "false",
      "security": "false",
      "option": null,
      "child": [
        {
          "type": "radio",
          "label": "No",
          "order": "25"
        },
        {
          "type": "radio",
          "label": "Yes",
          "order": "26"
        }
      ]
    },
    "3726": {
      "type": "image",
      "label": "Loft Photos",
      "default_value": null,
      "order": "27",
      "required": "false",
      "security": "false",
      "option": null
    }
  }
  </code></pre>
  
  <p>I am trying to Deserialize it to a list of objects of types defined in this class:</p>
  
  <pre><code>public class DBFormField
  {
      public string type { get; set; }
      public string label { get; set; }
      public string default_value { get; set; }
      public string order { get; set; }
      public string required { get; set; }
      public DBFormFieldOption option = new DBFormFieldOption();
      public List&lt;DBFormFieldChild&gt; child = new List&lt;DBFormFieldChild&gt;();
  }
  
  public class DBFormFieldOption
  {
      public List&lt;DBFormFieldGrid&gt; grid_rows = new List&lt;DBFormFieldGrid&gt;();
      public List&lt;DBFormFieldGrid&gt; grid_columns = new List&lt;DBFormFieldGrid&gt;();
      public string label1 { get; set; }
      public string label2 { get; set; }
      public string result_label { get; set; }
      public string operation { get; set; }
      public List&lt;string&gt; rows = new List&lt;string&gt;();
      public string tab_id { get; set; }
  }
  
  public class DBFormFieldChild
  {
      public string type { get; set; }
      public string label { get; set; }
      public string order { get; set; }
  }
  
  public class DBFormFieldGrid
  {
      public string title { get; set; }
      public string name { get; set; }
  }
  </code></pre>
  
  <p>I have tried a few strategies to do this. The latest, I was trying this <a href="http://james.newtonking.com/json/help/index.html?topic=html/T_Newtonsoft_Json_Converters_CustomCreationConverter_1.htm" rel="nofollow">http://james.newtonking.com/json/help/CustomCreationConverter</a></p>
  
  <p>For example:</p>
  
  <pre><code>List&lt;DBFormField&gt; parsedFields = new List&lt;DBFormField&gt;();
  parsedFields = JsonConvert.DeserializeObject&lt;List&lt;DBFormField&gt;&gt;(someFormObj.form_fields.ToString, new FormConverter());  // ToString???
  </code></pre>
  
  <p>...
     Public Class FormConverter
          Inherits Converters.CustomCreationConverter(Of DBFormField)</p>
  
  <pre><code>    Public Overrides Function Create(objectType As Type) As DBFormField
          Return New DBFormField()
      End Function
  End Class
  </code></pre>
  
  <p>I suspect putting .ToString on the end of the JObject is not good enough for the DeserializeObject method? See comment above. But this code throws the error...</p>
  
  <blockquote>
    <p>Cannot deserialize the current JSON object (e.g. {"name":"value"})
    into type 'System.Collections.Generic.List`1[RSAP.DBFormField]'
    because the type requires a JSON array (e.g. [1,2,3]) to deserialize
    correctly.</p>
  </blockquote>
  
  <p>I haven't tried serialising the JObject to a JSON string- this seems daft considering we have already parsed the JSON into a Jobject.</p>