title: how to create json array using jackson
body: <p>I need to create a json response for a report. Something like this:</p>
  
  <pre><code>var data = [
    ["", "Kia", "Nissan", "Toyota", "Honda"],
    ["2008", 10, 11, 12, 13],
    ["2009", 20, 11, 14, 13],
    ["2010", 30, 15, 12, 13]
  ];
  </code></pre>
  
  <p>Im using jackson library and i create a JsonGenerator, this is the code i have:</p>
  
  <pre><code>String[] cols = new String[5]; //Number of report columns
  
  JsonFactory jfactory = new JsonFactory();
  JsonGenerator jGenerator = jfactory.createJsonGenerator(response.getOutputStream(),JsonEncoding.UTF8);
  jGenerator.writeStartArray();
  
  jGenerator.writeStartArray();
  jGenerator.writeStringField(cols[0], "");
  //until...
  jGenerator.writeStringField(cols[4], "Honda");
  jGenerator.writeEndArray();
  jGenerator.writeStartArray();
  jGenerator.writeStringField(cols[0], "2008");
  //until...
  jGenerator.writeStringField(cols[4], "13");
  jGenerator.writeEndArray();
  //and the same with the next rows...
  
  jGenerator.writeEndArray();
  </code></pre>
  
  <p>The problem is when setting the first value i get this error:</p>
  
  <pre><code>org.codehaus.jackson.JsonGenerationException: Can not write a field name, expecting a value
  </code></pre>