我正在尝试使用Jackson和Jersey Servlets实现RESTful Web服务。我的Web服务可以生成这个特定的JSON,如图所示
{
"email":"aditya@123.com",
"source":{
"G":33.2470567,
"K":-95.89996559999997
},
"destination":{
"G":33.0198431,
"K":-96.69888559999998
},
"waypoints":[
{
"location":"Dallas, TX, USA",
"stopover":true
},
{
"location":"Houston, TX, USA",
"stopover":true
}
]
}
但是当我尝试使用相同的JSON时,它会产生内部服务器500错误:
org.codehaus.jackson.JsonParseException: Unexpected character ('Â' (code 194)): was expecting double-quote to start field name
我的POJO&网络服务如下所示:
@XmlRootElement
public class RiderVO {
private String email;
private MapLocation source;
private MapLocation destination;
private List<Waypoint> waypoints;
//getters and setters
}
@XmlRootElement
public class MapLocation {
private Double G;
private Double K;
//getters and setters
}
@XmlRootElement
public class Waypoint {
private String location;
private Boolean stopover;
//getters & setters
}
WEB服务:
@POST
@Path("/saveAll")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String saveRideJson(RiderVO riderVO){
//do something
}
我无法弄清楚什么时候它可以产生特定的JSON为什么我不能消耗它。我确实尝试更改布尔参数,并检查它的isVar setter问题是否为here。但即使这样也无法解决。任何建议都有帮助。提前谢谢!