title: How to wrap a List as top level element in JSON generated by Jackson
body: <p>I am running into a problem where I am trying to include a List as the root node, but I can't seem to be able to get this. Let me explain. Let's say we have a class "TestClass"</p>
  
  <pre><code>class TestClass{
      String propertyA;       
  }
  </code></pre>
  
  <p>Now, in some utility method this is what I do</p>
  
  <pre><code>String utilityMethod(){
     List&lt;TestClass&gt; list = someService.getList();
     new ObjectMapper().writeValueAsString(list); 
  }
  </code></pre>
  
  <p>The output I am trying to get in JSON is</p>
  
  <pre><code>{"ListOfTestClasses":[{"propertyA":"propertyAValue"},{"propertyA":"someOtherPropertyValue"}]}
  </code></pre>
  
  <p>I have tried to use</p>
  
  <pre><code>objMapper.getSerializationConfig().set(Feature.WRAP_ROOT_VALUE, true);
  </code></pre>
  
  <p>But, I still don't seem to get it right. </p>
  
  <p>Right now, I am just creating a Map &lt; String,TestClass > and I write that to achieve what I am trying to do, which works but clearly this is a hack. Could someone please help me with a more elegant solution? Thanks</p>