The java interface returns the json data format. The java interface returns the json data format.
The following code:
@ RequestMapping (value = "getCode1.html ")
@ ResponseBody
Public JSONObject getJSON (){
List <Map <Object, Object >>list = new ArrayList <> ();
Map <Object, Object> map = new HashMap <> ();
JSONObject json = new JSONObject ();
Map. put ("message", "111 ");
Map. put ("message2"," 222 ");
Map. put ("message3." 333 ");
Map. put ("message", "444 ");
Map. put ("message5", "555 ");
Map. put ("messagei6", "666 ");
List. add (map );
Json. accumulate ("messages", map );
Json. accumulate ("messages1", 123 );
Json. accumulate ("messages2", 456 );
Json. accumulate ("messages3", 789 );
Json. accumulate ("messages1", map );
Return json;
}
The returned result is:
{"Messages": {"message4": "444", "message3": "333", "message6": "666", "message5": "555 ", "message": "111", "message2": "222"}, "messages1": [123, {"message4": "444", "message3 ": "333", "message6": "666", "message5": "555", "message": "111", "message2": "222"}], "messages2": 456, "messages3": 789}