1
Rest Spring: 出力に何が起こったのか理解するには?Springのjsonのスラッシュ
@RestController
@RequestMapping("/person")
public class PersonController {
@Autowired
PersonService personService;
@RequestMapping(value = "/persons", method = RequestMethod.GET)
public String findAll() {
try {
List<Person> listModel = null;
listModel = personService.findAll();
Gson gson = new Gson();
System.out.println(gson.toJson(listModel));
return gson.toJson(listModel);
} catch (Exception e) {
return e.getMessage();
}
}
}
出す:
[{"ID":1,"firstName":"j","lastName":"s","nationalCode":1-86,"gender":"male","fatherName":"sss","deleted":"0"}]
が、ブラウザで(スラッシュ)である:
"[{\"ID\":1,\"firstName\":\"j\",\"lastName\":\"s\",\"nationalCode\":1-86,\"gender\":\"male\",\"fatherName\":\"sss\",\"deleted\":\"0\"}]"
、それは