JSON.Net Serialize Collection To Array of Arrays
<p>By default DataTables Ajax expects JSON data to be an array of arrays.</p>

<p>Using <code>JSON.Net</code> is it possible to serialize a collection into an array of arrays instead of an array of objects via an attribute/setting or does it have to be done via a custom <code>JsonConverter</code>. The object I am trying to serialize is as follows:</p>

<pre><code>public class DeviceIndex
{
    public int Id { get; set; }

    [Display(Name = "Asset Tag")]
    public string AssetTag { get; set; }

    [Display(Name = "Lease End")]
    [DataType(DataType.Date)]
    public DateTime LeaseEndDate { get; set; }

    public string Type { get; set; }

    [Display(Name = "Operating System")]
    public string OperatingSystem { get; set; }

    public string Model { get; set; }
}
</code></pre>

<p>And my controller action is as follows:</p>

<pre><code>public IActionResult IndexJson()
{
    var model = _db.Devices.Select(d =&gt; new DeviceIndex { ... }).ToList();
    return Content(JsonConvert.SerializeObject(new { data = model }), "application/json");
}
</code></pre>

<p>Which outputs the JSON:</p>

<pre><code>{
  "data": [
    {
      "Id": 1649,
      ...
    },
    {
      "Id": 703,
      ...
    }
  ]
}
</code></pre>

<p>Though my desired results are as follows:</p>

<pre><code>{
  "data": [
    [
      "1649",
      ...
    ],
    [
      "703",
      ...
    ]
  ]
}
</code></pre>

<p>I thought I could use the JsonArray attribute for my collection but it doesn't look to change the output.</p>

<pre><code>[JsonArray]
public class DevicesIndex: IEnumerable&lt;DeviceIndex&gt;
{
    List&lt;DeviceIndex&gt; devices;

    public IEnumerator&lt;DeviceIndex&gt; GetEnumerator()
    {
        return devices.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}
</code></pre>