title: Converting Java objects to JSON with Jackson
body: <p>I want my JSON to look like this:</p>
  
  <pre><code>{
      "information": [{
          "timestamp": "xxxx",
          "feature": "xxxx",
          "ean": 1234,
          "data": "xxxx"
      }, {
          "timestamp": "yyy",
          "feature": "yyy",
          "ean": 12345,
          "data": "yyy"
      }]
  }
  </code></pre>
  
  <p>Code so far:</p>
  
  <pre><code>import java.util.List;
  
  public class ValueData {
  
      private List&lt;ValueItems&gt; information;
  
      public ValueData(){
  
      }
  
      public List&lt;ValueItems&gt; getInformation() {
          return information;
      }
  
      public void setInformation(List&lt;ValueItems&gt; information) {
          this.information = information;
      }
  
      @Override
      public String toString() {
          return String.format("{information:%s}", information);
      }
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class ValueItems {
  
      private String timestamp;
      private String feature;
      private int ean;
      private String data;
  
  
      public ValueItems(){
  
      }
  
      public ValueItems(String timestamp, String feature, int ean, String data){
          this.timestamp = timestamp;
          this.feature = feature;
          this.ean = ean;
          this.data = data;
      }
  
      public String getTimestamp() {
          return timestamp;
      }
  
      public void setTimestamp(String timestamp) {
          this.timestamp = timestamp;
      }
  
      public String getFeature() {
          return feature;
      }
  
      public void setFeature(String feature) {
          this.feature = feature;
      }
  
      public int getEan() {
          return ean;
      }
  
      public void setEan(int ean) {
          this.ean = ean;
      }
  
      public String getData() {
          return data;
      }
  
      public void setData(String data) {
          this.data = data;
      }
  
      @Override
      public String toString() {
          return String.format("{timestamp:%s,feature:%s,ean:%s,data:%s}", timestamp, feature, ean, data);
      }
  }
  </code></pre>
  
  <p>I just missing the part how I can convert the Java object to JSON with Jackson:</p>
  
  <pre><code>public static void main(String[] args) {
     // CONVERT THE JAVA OBJECT TO JSON HERE
      System.out.println(json);
  }
  </code></pre>
  
  <p>My Question is: Are my classes correct? Which instance do I have to call and how that I can achieve this JSON output?</p>