title: JSONGenerator How to output an object in the JSON
body: <p>I want to output the following JSON:</p>
  
  <pre><code>result: {
      "x": 11,
      "y": 10,
      "actions": [
      ],
      "localConfigurations": {
           "local1": {},
           "local2":  {}
      }
  }
  </code></pre>
  
  <p>I have the following code:</p>
  
  <pre><code>public class Configuration {
      private int fX;
      private int fY;
      private Actions[] fActions;
      private LinkedHashMap&lt;String, LocalConfiguration&gt; fLocalConfigurations = new LinkedHashMap&lt;&gt;();
  
      @JsonProperty("x")
      public int getX() { return fX; }
      public void setX(int x) { fX = x; }
  
      @JsonProperty("y")
      // getter and setter for y
  
      @JsonProperty("actions")
      // getter and setter for actions
  
      @JsonProperty("localConfigurations")
      // getter and setter for localConfigurations
  }
  </code></pre>
  
  <p>Below is the code that I am trying to use to output the JSON:</p>
  
  <pre><code>    JsonFactory factory = new JsonFactory();
      JsonGenerator generator = factory.createGenerator(fOutputStream);
  
      generator.writeStartObject();
      generator.writeArrayFieldStart("result");
  
      if (configuration != null)
          mapper.writeValue(generator, configuration);
  
      generator.writeEndArray();
      generator.writeEndObject();
      generator.close();
  </code></pre>
  
  <p>However, my output turns out as:</p>
  
  <pre><code>result: [{
      "x": 11,
      "y": 10,
      "actions": [
      ],
      "localConfigurations": {
           "local1": {},
           "local2":  {}
      }
  }]
  </code></pre>
  
  <p>I am not sure how I can achieve the desired output, without using the generator.writeArrayFieldStart. If I use only writeStartObject and dump the object Configuration, the JSON output throws some errors instead.
  So, how can I get the output as I want?  thanks</p>