, . .
"null" ResponseEntity > , 0, "[]" JSON, "", . - , Gson.
:
@RequestMapping(value = "/test", produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<String> returnEmpty() {
List<GenericModel> genericModelList = new ArrayList<>();
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
String body = "";
if (genericModelList.size() == 0) {
body = "null";
} else {
body = gson.toJson(genericModelList);
}
return responseEntity = new ResponseEntity<>(body, headers, HttpStatus.OK);
}
, String JSON Gson Spring/Jackson, JSON. , String "null", List.size() == 0.