Java 获得;客户端发送的请求在语法上不正确;使用Spring REST和Jackson解析以下JSON时

Java 获得;客户端发送的请求在语法上不正确;使用Spring REST和Jackson解析以下JSON时,java,json,spring,rest,spring-mvc,Java,Json,Spring,Rest,Spring Mvc,使用Spring 4和Jackson 1.9.13,在进行rest调用时,我收到一个错误,返回到“客户端发送的请求在语法上不正确”,并且调用没有进入rest方法 JSON是这种数组格式: [ "location", [ { "regions":[], "x":10.0, "y":14.0, "timeExpires":1387219731911, "confidence":0.9, "timestamp":138

使用Spring 4和Jackson 1.9.13,在进行rest调用时,我收到一个错误,返回到“客户端发送的请求在语法上不正确”,并且调用没有进入rest方法

JSON是这种数组格式:

[ "location",
  [
    {
      "regions":[],
      "x":10.0,
      "y":14.0,
      "timeExpires":1387219731911,
      "confidence":0.9,
      "timestamp":1387219671911,
      "source":"wifi",
      "associated":true,
      "clientMac":"1c:4f:2b:14:c9:8b",
      "clientType":"AbC Device",
      "adspNetworkPath":"/a/b/c1",
      "folderID":10007,
      "floorNumber":1,
      "timeComputed":1387219671911
    },
    {
      "regions":[],
      "x":8.222222,
      "y":18.88889,
      "timeExpires":1387219726912,
      "confidence":0.9,
      "timestamp":1387219666912,
      "source":"wifi",
      "associated":true,
      "clientMac":"64:a3:ab:6b:5d:4f",
      "clientType":"123 Device",
      "adspNetworkPath":"/a/b/d1",
      "folderID":10007,
      "floorNumber":1,
      "timeComputed":1387219666912
    }
  ]
]
Spring控制器看起来像:

@RequestMapping(value="/location", method=RequestMethod.POST)
  public @ResponseBody void locationData(@RequestBody List<Location> locationList) {
    logger.info("Inside locationData() method...");

    ObjectMapper mapper = new ObjectMapper();
    try {
        // just convert to list of object and display back for now...           
        String jsonString = mapper.writeValueAsString(locationList);
        logger.info(jsonString);
    } catch (IOException e) {
        e.printStackTrace();
    }
  }
@RequestMapping(value=“/location”,method=RequestMethod.POST)
public@ResponseBody void locationData(@RequestBody List locationList){
info(“内部位置数据()方法…”);
ObjectMapper mapper=新的ObjectMapper();
试一试{
//现在只需转换到对象列表并显示回来。。。
字符串jsonString=mapper.writeValueAsString(locationList);
logger.info(jsonString);
}捕获(IOE异常){
e、 printStackTrace();
}
}
模型对象就是我遇到问题的地方

package com.tester;

import java.util.List;

import org.codehaus.jackson.annotate.JsonProperty;

public class Location {
    private String location;
    private List<AdspData> locationArray;

    @JsonProperty(value = "location")
    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @JsonProperty(value = "location-array")
    public List<AdspData> getLocationArray() {
        return locationArray;
    }

    public void setLocationArray(List<Data> locationArray) {
        this.locationArray = locationArray;
    }

    @Override
    public String toString() {
        return "Location [location=" + location + ", locationArray="
                + locationArray + "]";
    }
}
package.com.tester;
导入java.util.List;
导入org.codehaus.jackson.annotate.JsonProperty;
公共类位置{
私有字符串位置;
私有列表位置数组;
@JsonProperty(value=“location”)
公共字符串getLocation(){
返回位置;
}
公共void集合位置(字符串位置){
这个位置=位置;
}
@JsonProperty(value=“位置数组”)
公共列表getLocationArray(){
返回定位阵列;
}
公共void setLocationArray(列表locationArray){
this.locationArray=locationArray;
}
@凌驾
公共字符串toString(){
返回“Location[Location=“+Location+”,locationArray=”
+locationArray+“]”;
}
}
其他车型类别:

package com.tester;

import java.util.ArrayList;
import java.util.Date;

import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.tester.util.JsonDateSerializer;

public class AdspData {
    private ArrayList<String> regions;
    private double xLoc;
    private double yLoc;
    private double confidence;
    private Date timeExpires;
    private Date timeStamp;
    private Date timeComputed;
    private String source;
    private String clientMac;
    private String clientType;
    private String adspNetworkPath;
    private int folderId;
    private int floorNumber;
    private boolean associated;

    public AdspData() {     
    }

    @JsonProperty(value = "regions")
    public ArrayList<String> getRegions() {
        return regions;
    }

    public void setRegions(ArrayList<String> regions) {
        this.regions = regions;
    }

    @JsonProperty(value = "x")
    public double getxLoc() {
        return xLoc;
    }

    public void setxLoc(double xLoc) {
        this.xLoc = xLoc;
    }

    @JsonProperty(value = "y")
    public double getyLoc() {
        return yLoc;
    }

    public void setyLoc(double yLoc) {
        this.yLoc = yLoc;
    }

    @JsonProperty(value = "confidence")
    public double getConfidence() {
        return confidence;
    }

    public void setConfidence(double confidence) {
        this.confidence = confidence;
    }

    @JsonProperty(value = "timeExpires")
    @JsonSerialize(using = JsonDateSerializer.class)
    public Date getTimeExpires() {
        return timeExpires;
    }

    public void setTimeExpires(Date timeExpires) {
        this.timeExpires = timeExpires;
    }

    @JsonProperty(value = "timestamp")
    @JsonSerialize(using = JsonDateSerializer.class)
    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
    }

    @JsonProperty(value = "timeComputed") 
    @JsonSerialize(using = JsonDateSerializer.class)
    public Date getTimeComputed() {
        return timeComputed;
    }

    public void setTimeComputed(Date timeComputed) {
        this.timeComputed = timeComputed;
    }

    @JsonProperty(value = "source")
    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    @JsonProperty(value = "clientMac")
    public String getClientMac() {
        return clientMac;
    }

    public void setClientMac(String clientMac) {
        this.clientMac = clientMac;
    }

    @JsonProperty(value = "clientType")
    public String getClientType() {
        return clientType;
    }

    public void setClientType(String clientType) {
        this.clientType = clientType;
    }

    @JsonProperty(value = "adspNetworkPath")
    public String getAdspNetworkPath() {
        return adspNetworkPath;
    }

    public void setAdspNetworkPath(String adspNetworkPath) {
        this.adspNetworkPath = adspNetworkPath;
    }

    @JsonProperty(value = "folderID")
    public int getFolderId() {
        return folderId;
    }

    public void setFolderId(int folderId) {
        this.folderId = folderId;
    }

    @JsonProperty(value = "floorNumber")
    public int getFloorNumber() {
        return floorNumber;
    }

    public void setFloorNumber(int floorNumber) {
        this.floorNumber = floorNumber;
    }

    @JsonProperty(value = "associated")
    public boolean isAssociated() {
        return associated;
    }

    public void setAssociated(boolean associated) {
        this.associated = associated;
    }

    @Override
    public String toString() {
        return "AdspData [regions=" + regions + ", xLoc=" + xLoc
                + ", yLoc=" + yLoc + ", confidence=" + confidence
                + ", timeExpires=" + timeExpires + ", timeStamp=" + timeStamp
                + ", timeComputed=" + timeComputed + ", source=" + source
                + ", clientMac=" + clientMac + ", clientType=" + clientType
                + ", adspNetworkPath=" + adspNetworkPath + ", folderId="
                + folderId + ", floorNumber=" + floorNumber + ", associated="
                + associated + "]";
    }
}
package.com.tester;
导入java.util.ArrayList;
导入java.util.Date;
导入org.codehaus.jackson.annotate.JsonProperty;
导入org.codehaus.jackson.map.annotate.JsonSerialize;
导入com.tester.util.JsonDateSerializer;
公共类AdspData{
私有ArrayList区域;
私人双xLoc;
私家双联;
私人双重信任;
私人日期时间到期;
私有日期时间戳;
计算私人日期时间;
私有字符串源;
私有字符串clientMac;
私有字符串clientType;
专用字符串adspNetworkPath;
私有int folderId;
私人国际楼层编号;
私有布尔关联;
公共AdspData(){
}
@JsonProperty(value=“regions”)
公共阵列列表getRegions(){
返回区;
}
公共无效集合区域(ArrayList区域){
这个区域=区域;
}
@JsonProperty(value=“x”)
公共双getxLoc(){
返回xLoc;
}
公共无效setxLoc(双xLoc){
this.xLoc=xLoc;
}
@JsonProperty(value=“y”)
公共双getyLoc(){
返回yLoc;
}
公共无效塞梯洛克(双重塞梯洛克){
this.yLoc=yLoc;
}
@JsonProperty(value=“confidence”)
公众信心{
恢复信心;
}
公众信心(双重信心){
信心=信心;
}
@JsonProperty(value=“timeExpires”)
@JsonSerialize(使用=JsonDateSerializer.class)
公共日期getTimeExpires(){
返回时间到期;
}
公共无效setTimeExpires(日期timeExpires){
this.timeExpires=timeExpires;
}
@JsonProperty(value=“timestamp”)
@JsonSerialize(使用=JsonDateSerializer.class)
公共日期getTimeStamp(){
返回时间戳;
}
public void setTimeStamp(日期时间戳){
this.timeStamp=时间戳;
}
@JsonProperty(value=“timeComputed”)
@JsonSerialize(使用=JsonDateSerializer.class)
公共日期getTimeComputed(){
计算返回时间;
}
公共无效setTimeComputed(日期时间计算){
this.timeComputed=timeComputed;
}
@JsonProperty(value=“source”)
公共字符串getSource(){
返回源;
}
公共void集合源(字符串源){
this.source=源;
}
@JsonProperty(value=“clientMac”)
公共字符串getClientMac(){
返回clientMac;
}
public void setClientMac(字符串clientMac){
this.clientMac=clientMac;
}
@JsonProperty(value=“clientType”)
公共字符串getClientType(){
返回clientType;
}
公共void setClientType(字符串clientType){
this.clientType=clientType;
}
@JsonProperty(value=“adspNetworkPath”)
公共字符串getAdspNetworkPath(){
返回ADSP网络路径;
}
public void setAdspNetworkPath(字符串adspNetworkPath){
this.adspNetworkPath=adspNetworkPath;
}
@JsonProperty(value=“folderID”)
public int getFolderId(){
返回folderId;
}
公共无效setFolderId(int folderId){
this.folderId=folderId;
}
@JsonProperty(value=“floorNumber”)
public int getFloorNumber(){
返回楼层号;
}
公共无效setFloorNumber(整数floorNumber){
this.floorNumber=floorNumber;
}
@JsonProperty(value=“关联”)
公共布尔值关联(){
关联回报;
}
公共void集合关联(布尔关联){
这是关联的;
}
@凌驾
公共字符串toString(){
返回“AdspData[regions=“+regions+”,xLoc=“+xLoc
+“,yLoc=“+yLoc+”,confidence=“+confidence
+“,timeExpires=“+timeExpires+”,timeStamp=“+timeStamp
+“,timeComputed=“+timeComputed+”,source=“+source
+,clientMac=“+clientMac+”,clientType=“+clientType
+“,adspNetworkPath=“+adspNetworkPath+”,folderId=”
+folderId+”,floorNumber=“+floorNumber+”,关联=”
+关联+“]”;
}
}
[
  {
    "location": "Location Data",
    "locationArray": [
      {
        "regions": [],
        "x": 10.0,
        "y": 14.0,
        "timeExpires": 1387219731911,
        "confidence": 0.9,
        "timestamp": 1387219671911,
        "source": "wifi",
        "associated": true,
        "clientMac": "1c:4f:2b:14:c9:8b",
        "clientType": "AbC Device",
        "adspNetworkPath": "/a/b/c1",
        "folderID": 10007,
        "floorNumber": 1,
        "timeComputed": 1387219671911
      },
      {
        "regions": [],
        "x": 8.222222,
        "y": 18.88889,
        "timeExpires": 1387219726912,
        "confidence": 0.9,
        "timestamp": 1387219666912,
        "source": "wifi",
        "associated": true,
        "clientMac": "64:a3:ab:6b:5d:4f",
        "clientType": "123 Device",
        "adspNetworkPath": "/a/b/d1",
        "folderID": 10007,
        "floorNumber": 1,
        "timeComputed": 1387219666912
      }
    ]
  }
]