Esempio n. 1
0
  @RequestMapping()
  @ResponseBody
  public ResponseEntity<String> listJson() {
    List<Country> result = Country.listAllCountriesWithProducts();

    return new ResponseEntity<String>(
        getJSONSerializer().serialize(result), jsonFactory.createJSONHTTPHeaders(), HttpStatus.OK);
  }
Esempio n. 2
0
  @RequestMapping(value = "/{id}")
  @ResponseBody
  public ResponseEntity<String> showJson(@PathVariable("id") Long id) {
    Country item = Country.findCountry(id);

    if (item == null) {
      return new ResponseEntity<String>(jsonFactory.createJSONHTTPHeaders(), HttpStatus.NOT_FOUND);
    }

    return new ResponseEntity<String>(
        getJSONSerializer().serialize(item), jsonFactory.createJSONHTTPHeaders(), HttpStatus.OK);
  }