title: Java - Spring return JSON object / array
body: <p>I have a basic Rest Controller which returns a list of models in json to the client:</p>
  
  <pre><code>@RestController
  public class DataControllerREST {
  
      @Autowired
      private DataService dataService;
  
      @GetMapping("/data")
      public List&lt;Data&gt; getData() {
          return dataService.list();
      }
  
  }
  </code></pre>
  
  <p>Which returns data in this format:</p>
  
  <pre><code>[
  
      {
          "id": 1,
          "name": "data 1",
          "description": "description 1",
          "active": true,
          "img": "path/to/img"
      },
      // etc ...
  
  ]
  </code></pre>
  
  <p>Thats great for starting, but i thought about returning data of this format:</p>
  
  <pre><code>[
      "success": true,
      "count": 12,
      "data": [
          {
              "id": 1,
              "name": "data 1",
              "description": "description 1",
              "active": true,
              "img": "path/to/img"
          },
          {
              "id": 2,
              "name": "data 2",
              "description": "description 2",
              "active": true,
              "img": "path/to/img"
          },
      ]
      // etc ...
  
  ]
  </code></pre>
  
  <p>But i am not sure about this issue as i can not return any class as JSON... anybody has suggestions or advices?</p>
  
  <p>Greetings and thanks!</p>