how to get the JSON data in Spring controller?

java, jquery, json, spring, spring-mvc

Solution

var json = {"message":"Message123","time":"time123","name":"test123"}
data : JSON.stringify(json) should have a key , 

data : {json:{"message":"Message123","time":"time123","name":"test123"}},
url:/json/test

Controller

@RequestMapping(value = {"json/test"},method = RequestMethod.GET)
    @ResponseBody
    public String jsonTest(String json){
       JSONObject jsonObject = JSONObject.fromObject(json);
        String m = jsonObject.get("message").toString();
        String t = jsonObject.get("time").toString();
        String n = jsonObject.get("name").toString();
    }

I use the `net.sf.json.JSONObject`

Problem

I know it is a simple one . But couldn't find a solution. My jQuery-ajax will be , ``` var json = {"message":"Message123","time":"time123","name":"test123"} data : JSON.stringify(json), ``` My Spring controller will be , ``` @RequestMapping(value = "chat.html", method=RequestMethod.GET ) public @ResponseBody String getChat() { System.out.println("Entered in to the controller "); String name == ??? String msg == ??? String time == ??? //Process the functionality using the msg,name,time return "Json String"; } ``` How can I get the values of the name, message , time. Hope our stack members will help me.

Original source