title: Serializing a List of Objects in Java to json
body: <p>Currently i am trying to serialize a list of objects to array using Jackson . The Scenario here is if the list contains only one element , the list should be serialised as an object but not like an array . Is there any provision to do that?</p>
  
  <p>I Created a Java Model and i am serialising to JSON using the below Code</p>
  
  <pre><code>A testObject = new A();
      ObjectMapper mapper = new ObjectMapper();           
              String json = mapper.writeValueAsString(testObject);
              System.out.append (json)
  </code></pre>
  
  <p>DataModel</p>
  
  <pre><code>class A{
  private B b;
  }
  
  Class B{
  private ArrayList&lt;C&gt; c;
  }
  
  Class c
  {
  private int i;
  private String test;
  }
  </code></pre>