title: Serializing a hierarchy of plain C# objects to a JSON array
body: <p>I have a class structure in C#, similar to the following:</p>
  
  <pre><code>[DataContract]
  class Data
  {
      [DataMember] public List&lt;Hotel&gt; Hotels { get; set; }
      // etc...
  }
  
  [DataContract]
  class Hotel
  {
      [DataMember] public int HotelID { get; set; }
      [DataMember] public string HotelName { get; set; }
      // etc...
  }
  </code></pre>
  
  <p>I've been serializing this to JSON, using the 'DataContractJsonSerializer'.</p>
  
  <p>However, because JSON includes all the property names, this makes for a  lot of redundant text.</p>
  
  <p>(You might say gZip alleviates this, but I believe gZip compresses only a portion of the output, like the first n kilobytes, so in this case, it's not really going to help.)</p>
  
  <p>So what I'd prefer to do is spit out the data in the format of a Javascript array, like this:</p>
  
  <pre><code>[[1, "firstHotel"], [2, "secondHotel"], [3, "thirdHotel"], ...]
  </code></pre>
  
  <p>Is there any way of customizing the JSON serialization to do it this way? Or should I just manually write my own serializer?</p>