我有一个 Web 服务 REST:
@Path("/Vehicles")
public class Vehicles{
@GET
@Path("/Cars")
@Produces(aplicattion/json)
public String Cars() {
Car[] cars = Consulting my database...
Gson gson = new Gson();
return gson.toJson(cars);
}
我使用网络服务:
try {
HttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet(
"http://localhost:8080/Concessionaire/rest/Vehicles/Cars");
HttpResponse resp = httpClient.execute(get);
String respGET = EntityUtils.toString(resp.getEntity());
Gson gson = new Gson();
Cars[] c = gson.fromJson(respGET,Cars[].class);
}catch(Exception e){
}
但是出现了这个异常: Expected BEGIN_ARRAY but was String at line 1 colum 6 有什么问题?