title: How can I serialise a string array to JSON using DataContractJsonSerializer?
body: <p>This seems to be the same question as below but that answer hasn't resolved it:</p>
  
  <p><a href="https://stackoverflow.com/questions/8204320/deserializing-a-simple-json-array-with-datacontractjsonserializer">Deserializing a Simple JSON Array</a></p>
  
  <p>I am using DataContractJsonSerializer to convert from XML to JSON and vice versa. Everything works with complex data types and arrays of complex data types but I'm having a problem producing JSON for a string array.</p>
  
  <p>The JSON I need to produce should have this structure:</p>
  
  <pre><code>{
    "data": {
      "x_axis": {
        "labels": [ "Jan", "Feb", "Mar", "Apr","May", "Jun", "Jul", Aug","Sep", Oct", "Nov", "Dec" ]
       }
    }
  }
  </code></pre>
  
  <p>The objects I am using are:-</p>
  
  <p>LineChartData:</p>
  
  <pre><code>[DataContract]
  public class LineChartData
  {
      [DataMember(Name = "x_axis")]
      public LineChartXAxis XAxis { get; set; }
  }
  </code></pre>
  
  <p>LineChartXAxis:</p>
  
  <pre><code>[DataContract]
  public class LineChartXAxis
  {
      [DataMember(Name = "labels")]
      public string[] Labels { get; set; }
  }
  </code></pre>
  
  <p>The XML I am trying to convert looks like this:</p>
  
  <pre><code>&lt;LineChartData&gt;
    &lt;XAxis&gt;
      &lt;Labels&gt;Jan&lt;/Labels&gt;
      &lt;Labels&gt;Feb&lt;/Labels&gt;
      &lt;Labels&gt;Mar&lt;/Labels&gt;
      &lt;Labels&gt;Apr&lt;/Labels&gt;
      &lt;Labels&gt;May&lt;/Labels&gt;
      &lt;Labels&gt;Jun&lt;/Labels&gt;
      &lt;Labels&gt;Jul&lt;/Labels&gt;
      &lt;Labels&gt;Aug&lt;/Labels&gt;
      &lt;Labels&gt;Sep&lt;/Labels&gt;
      &lt;Labels&gt;Oct&lt;/Labels&gt;
      &lt;Labels&gt;Nov&lt;/Labels&gt;
      &lt;Labels&gt;Dec&lt;/Labels&gt;
    &lt;/XAxis&gt;
  &lt;/LineChartData&gt;
  </code></pre>
  
  <p>My deserialising code is:</p>
  
  <pre><code>var serialiser = new XmlSerializer(typeof(LineChartData));
  var stringReader = new StringReader(xml);
  
  var result = serialiser.Deserialize(stringReader);
  </code></pre>
  
  <p>The JSON I get back always has an empty labels array:</p>
  
  <pre><code>{
    "data": {
      "x_axis": {
        "labels":[]
      }
    }
  }
  </code></pre>
  
  <p>How should I be defining the Labels property in LineChartXAxis to serialise the JSON correctly?</p>