Unexpected token END OF FILE at position 0

2019-07-20 17:07发布

问题:

{ @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();
        }
     }

when I am sending request through some REST Client, it works but when the service is invoked I get exception:

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)

the data sent is :

{"date":"2013.10.15","imei":"357506058783585","log":[{"values":["3974","52.4886077","13.3451314","fused","45.1","0.0","Fuss","hand"]},{"values":["5039","52.4885826","13.3451278","fused","30.615","0.0","Fuss","hand"]},{"values":["6132","52.4883742","13.3451155","fused","9.999","14.425955","Fuss","hand"]},{"values":["7175","52.4883443","13.3451756","fused","5.804","8.616628","Fuss","hand"]},{"values":["8547","52.4883246","13.3451825","fused","4.637","4.2895117","Fuss","hand"]},{"values":["8987","52.4883246","13.3451825","fused","4.637","4.2895117","Fuss","hand"]},{"values":["9575","52.4883244","13.3451717","fused","3.549","2.1017656","Fuss","hand"]},{"values":["10936","52.4883321","13.3451635","fused","2.759","0.43061575","Fuss","hand"]},{"values":["12534","52.4883403","13.3451613","fused","2.745","0.30459246","Fuss","hand"]},{"values":["13525","52.4883725","13.3451524","fused","2.602","2.3170655","Fuss","hand"]},{"values":["14112","52.4883725","13.3451524","fused","2.602","2.3170655","Fuss","hand"]},{"values":["14584","52.4884197","13.3451565","fused","2.591","3.8196104","Fuss","hand"]},{"values":["15547","52.4884804","13.3451602","fused","2.517","5.5030336","Fuss","hand"]},{"values":["16747","52.4885435","13.3451637","fused","2.991","6.379675","Fuss","hand"]},{"values":["17565","52.4886217","13.3451611","fused","3.186","7.3437247","Fuss","hand"]},{"values":["18524","52.4887021","13.3451604","fused","3.173","8.259222","Fuss","hand"]},{"values":["19001","52.4887021","13.3451604","fused","3.173","8.259222","Fuss","hand"]},{"values":["19536","52.4887899","13.3451602","fused","3.194","8.925519","Fuss","hand"]},{"values":["20567","52.4888802","13.3451579","fused","3.211","9.300699","Fuss","hand"]},{"values":["21529","52.4889692","13.3451543","fused","3.177","9.773389","Fuss","hand"]},{"values":["23013","52.4890775","13.3451577","fused","2.728","8.770022","Fuss","hand"]},{"values":["24064","52.4890775","13.3451577","fused","2.728","8.770022","Fuss","hand"]},{"values":["24567","52.4892591","13.3451592","fused","2.737","11.797656","Fuss","hand"]},{"values":["25518","52.4893716","13.3451574","fused","2.585","12.592365","Fuss","hand"]},{"values":["26532","52.4894861","13.3451609","fused","2.566","12.596952","Fuss","hand"]},{"values":["27589","52.4896041","13.3451711","fused","2.544","12.547134","Fuss","hand"]},{"values":["28712","52.4897229","13.3451761","fused","3.093","12.144053","Fuss","hand"]},{"values":["29799","52.4897229","13.3451761","fused","3.093","12.144053","Fuss","hand"]}],"userid":"John","tripStartTime":1381819057588,"tripId":2,"recid":1}