title: Serialise a 2D array for Json
body: <p>I am having difficulty with serialisation.  I have an aspx page that uses an ajax call to return objects from the server side.</p>
  
  <p>Desired output </p>
  
  <p>ModelPoints=[[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]] (for WebGL)</p>
  
  <p>Actual output
  ModelPoints={{Points=[1,2,3]},{Points=[1,2,3]},{Points=[1,2,3]},{Points=[1,2,3]}}</p>
  
  <p>The application flow is</p>
  
  <p>Ajax -> Aspx -> WCF -> Aspx -> Ajax</p>
  
  <p>Below are the classes that are being serialized incorrectly.  How do i restructure this so that it works? I do not want to parse 18000+ pts more than once, so the output from the server should be the correct format. i.e. I cannot afford to parse it on the client side.</p>
  
  <p>The object name Points comes from the parameter name, how to do this for a 2D array of floats.</p>
  
  <p>The classes below</p>
  
  <pre><code>[Serializable()]
  public class ModelPoint
  {
      public ModelPoint()
      {
      }
      public ModelPoint(float x, float y, float z)
      {
          _points = new List&lt;Nullable&lt;float&gt;&gt;();
          _points.Add(x);
          _points.Add(y);
          _points.Add(z);
      }
      private List&lt;Nullable&lt;float&gt;&gt; _points;
      public List&lt;Nullable&lt;float&gt;&gt; Points
      {
          get {return _points;}
          set { _points = value; }
      }
  }
  
  [Serializable()]
  public class Model
  {
      private List&lt;ModelPoint&gt; _modelPoints;
  
      [System.Xml.Serialization.XmlArray("ModelPoints", IsNullable = true)]
      [System.Xml.Serialization.XmlArrayItem()]
      public List&lt;ModelPoint&gt; ModelPoints 
      {
          get {return _modelPoints;}
          set { _modelPoints = value; }
      }
  }
  </code></pre>