Returning JsonObject using @ResponseBody in SpringMVC
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using the new Java API (JSR 353) for JSON in a SpringMVC project. The idea is to generate some piece of Json data and have it returned to the client. The controller I have look somewhat like this: @RequestMapping("/test") @ResponseBody public JsonObject test() { JsonObject result = Json.createObjectBuilder() .add("name", "Dade") .add("age", 23) .add("married", false) .build(); return result; } And when I access this, instead of getting the expected representation of the JSON, I get these instead: {"name":{"chars":"Dade","string":"Dade",