{ @RequestMapping(value = "/sensorlog", method = RequestMethod.POST)
public @ResponseBody String sensorlog(HttpServletRequest request)
{
String jsonObject=request.getParameter("RawData");
JSONParser parser = new JSONParser();
try{
Object obj = parser.parse(jsonObject);
JSONObject inputData = (JSONObject) obj;
String date = (String) inputData.get("date");
System.out.println(date);
String userId = (String) inputData.get("userid");
System.out.println(userId);
} catch(Exception e)
{
e.printStackTrace();
}
}
当我通过某个REST客户端发送请求时,它可以正常工作,但是当调用该服务时,我会遇到异常:
Unexpected token END OF FILE at position 0.
at org.json.simple.parser.JSONParser.parse(JSONParser.java:257)
at org.json.simple.parser.JSONParser.parse(JSONParser.java:81)
at org.json.simple.parser.JSONParser.parse(JSONParser.java:75)
at com.kathrina.user.controller.UserController.sensorlog(UserController.java:211)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
发送的数据是:
{ “日期”: “2013年10月15日”, “IMEI”: “357506058783585”, “日志”:[{ “值”:[ “3974”, “52.4886077”, “13.3451314”, “稠合的”,” 45.1" , “0.0”, “忙乱”, “手”]},{ “值”:[ “5039”, “52.4885826”, “13.3451278”, “稠合的”, “30.615”, “0.0”, “忙乱” , “手”]},{ “值”:[ “6132”, “52.4883742”, “13.3451155”, “稠合的”, “9.999”, “14.425955”, “忙乱”, “手”]},{“值“:[” 7175" , “52.4883443”, “13.3451756”, “稠合的”, “5.804”, “8.616628”, “忙乱”, “手”]},{ “值”:[ “8547”, “52.4883246” “13.3451825”, “稠合的”, “4.637”, “4.2895117”, “忙乱”, “手”]},{ “值”:[ “8987”, “52.4883246”, “13.3451825”, “稠合的”,” 4.637" , “4.2895117”, “忙乱”, “手”]},{ “值”:[ “9575”, “52.4883244”, “13.3451717”, “稠合的”, “3.549”, “2.1017656”, “忙乱” , “手”]},{ “值”:[ “10936”, “52.4883321”, “13.3451635”, “稠合的”, “2.759”, “0.43061575”, “忙乱”, “手”]},{“值“:[” 12534" , “52.4883403”, “13.3451613”, “稠合的”, “2.745”, “0.30459246”, “忙乱”, “手”]},{ “值”:[ “13525”, “52.4883725” “13.3451524”, “稠合的”, “2.602”, “2.3170655”, “忙乱”, “手”]},{ “值”:[ “14112”, “52.4883725”, “13.3451524”, “稠合的”,” 2.602" , “2.3170655” “忙乱”, “手”]},{ “值”:[ “14584”, “52.4884197”, “13.3451565”, “稠合的”, “2.591”, “3.8196104”, “忙乱”, “手”]} ,{ “值”:[ “15547”, “52.4884804”, “13.3451602”, “稠合的”, “2.517”, “5.5030336”, “忙乱”, “手”]},{ “值”:[ “16747” “52.4885435”, “13.3451637”, “稠合的”, “2.991”, “6.379675”, “忙乱”, “手”]},{ “值”:[ “17565”, “52.4886217”, “13.3451611”,”稠合的”, “3.186”, “7.3437247”, “忙乱”, “手”]},{ “值”:[ “18524”, “52.4887021”, “13.3451604”, “稠合的”, “3.173”, “8.259222” “忙乱”, “手”]},{ “值”:[ “19001”, “52.4887021”, “13.3451604”, “稠合的”, “3.173”, “8.259222”, “忙乱”, “手”]} ,{ “值”:[ “19536”, “52.4887899”, “13.3451602”, “稠合的”, “3.194”, “8.925519”, “忙乱”, “手”]},{ “值”:[ “20567” “52.4888802”, “13.3451579”, “稠合的”, “3.211”, “9.300699”, “忙乱”, “手”]},{ “值”:[ “21529”, “52.4889692”, “13.3451543”,”稠合的”, “3.177”, “9.773389”, “忙乱”, “手”]},{ “值”:[ “23013”, “52.4890775”, “13.3451577”, “稠合的”, “2.728”, “8.770022” “忙乱”, “手”]},{ “值”:[ “24064”, “52.4890775”, “13.3451577”, “稠合的”, “2.728”, “8.770022”, “忙乱”, “手”]} ,{ “值”:[” 24567" , “52.4892591”, “13.3451592”, “稠合的”, “2.737”, “11.797656”, “忙乱”, “手”]},{ “值”:[ “25518”, “52.4893716”, “13.3451574” , “稠合的”, “2.585”, “12.592365”, “忙乱”, “手”]},{ “值”:[ “26532”, “52.4894861”, “13.3451609”, “稠合的”, “2.566”,” 12.596952" , “忙乱”, “手”]},{ “值”:[ “27589”, “52.4896041”, “13.3451711”, “稠合的”, “2.544”, “12.547134”, “忙乱”, “手” ]},{ “值”:[ “28712”, “52.4897229”, “13.3451761”, “稠合的”, “3.093”, “12.144053”, “忙乱”, “手”]},{ “值”:[” 29799" , “52.4897229”, “13.3451761”, “融合”, “3.093”, “12.144053”, “小题大做”, “手”]}], “用户ID”: “约翰”, “tripStartTime”:1381819057588,“TRIPID “:2”,recid“:1}