It returns true or false. And you are right that this is not json.
It cannot be json, because it is not an object, it is simply primitive, therefore its fine as is - it will be assigned to the javascript variable in your success handler.
If you return the list of Booleans, you will get an array:
[true,false,true]
If you must form json completely, do not return the primitive, use hashmap or a custom shell object.
public @ResponseBody Map<String, Boolean> getTrue() { Map<String, Boolean> map = new HashMap<String, Boolean>(1){{put("result", Boolean.TRUE);}}; return map; }
Returning a hash map is perhaps the easiest and best way to get the json you need:
{"result":true}
Nimchimpsky
source share