I have a class structure in C#, similar to the following:
[DataContract]
class Data
{
[DataMember] public List<Hotel> Hotels { get; set; }
// etc...
}
[DataContract]
class Hotel
{
[DataMember] public int HotelID { get; set; }
[DataMember] public string HotelName { get; set; }
// etc...
}
I've been serializing this to JSON, using the 'DataContractJsonSerializer'.
However, because JSON includes all the property names, this makes for a lot of redundant text.
(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.)
So what I'd prefer to do is spit out the data in the format of a Javascript array, like this:
[[1, "firstHotel"], [2, "secondHotel"], [3, "thirdHotel"], ...]
Is there any way of customizing the JSON serialization to do it this way? Or should I just manually write my own serializer?