我在使用 RestTemplate 请求 RESTful API ,获取服务端响应的时候出现了这样的一个错误
Could not read document: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token
最开始的时候是这样写的
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
后来改成这样就好了
ResponseEntity<JSONObject> response = restTemplate.getForEntity(url, JSONObject.class);
可能是因为服务端返回的是 JSON ,而我却用 String 来接收返回的数据,所以才出现了这样的错误。
1、Can not deserialize instance of java.lang.String out of START_OBJECT token
http://blog.csdn.net/smileiam/article/details/49964289