我在我的网络服务中使用jackson框架。我正在发送JSON数据,但我收到了一些错误

时间:2016-07-08 21:03:04

标签: java android json pojo

以下是我的代码。我的POJO代码有什么问题吗?

错误

  

[simple type,class com.data.Request $ Track_trips $ Track_points]值的实例化失败:null(通过引用链:com.data.Request [" track_trips"] - > java.util .ArrayList [0] - > com.data.Track_trips [" track_points"] - > java.util.ArrayList中[120])*

这是我的POJO

public class Request {
public final String description;
public final String name;
public final String reference;
public final String tId;
public final String transactionTime;
public final List<Track_trips> track_trips;

@JsonCreator
public Request(@JsonProperty(value="description", required=false) String description, @JsonProperty(value="name", required=false) String name,
                   @JsonProperty(value="reference", required=false) String reference, @JsonProperty(value="tId", required=false) String tId,
                   @JsonProperty(value="transactionTime", required=false) String transactionTime, @JsonProperty(value="track_trips", required=false) List<Track_trips> track_trips){
    this.description = description;
    this.name = name;
    this.reference = reference;
    this.tId = tId;
    this.transactionTime = transactionTime;
    this.track_trips = track_trips;
}

public static class Track_trips {
    public final String endDate;
    public final String startDate;
    public final List<Track_points> track_points;
    public final String tripId;
    public final long tripMile;

    @JsonCreator
    public Track_trips(@JsonProperty(value="endDate", required=false) String endDate, @JsonProperty(value="startDate", required=false) String startDate,
                       @JsonProperty(value="track_points", required=false) List<Track_points> track_points,
                       @JsonProperty(value="tripId", required=false) String tripId, @JsonProperty(value="tripMile", required=false) long tripMile){
        this.endDate = endDate;
        this.startDate = startDate;
        this.track_points = track_points;
        this.tripId = tripId;
        this.tripMile = tripMile;
    }


    public static class Track_points {
        public final String time;
        public final long ele;
        public final long heading;
        public final double lat;
        public final double lon;
        public final long satellites;
        public final long speed;

        @JsonCreator
        public Track_points(@JsonProperty(value="transactionTime", required=false) String time, @JsonProperty(value="ele", required=false) long ele,
                            @JsonProperty(value="heading", required=false) long heading, @JsonProperty(value="lat", required=false) double lat,
                            @JsonProperty(value="lon", required=false) double lon, @JsonProperty(value="satellites", required=false) Long satellites,
                            @JsonProperty(value="speed", required=false) long speed){
            this.time = time;
            this.ele = ele;
            this.heading = heading;
            this.lat = lat;
            this.lon = lon;
            this.satellites = satellites;
            this.speed = speed;

        }
    }
}

}

JSON

{
  "description": "trail format",
  "name": "App Name",
  "reference": "fcacfa66-8c86-40cf-b7c4-f4cd4a4722d5",
  "tId": "944e61be-0c28-4390-9f7a-4204b8ea4e9c",
  "transactionTime": "2015-11-21T09:52:33.000Z",
  "track_trips": [
    {
      "endDate": "2016-07-06T14:52:33.000Z",
      "startDate": "2016-07-06T14:52:33.000Z",
      "track_points": [
        {
          "time": "2016-07-06T14:52:33.000Z",
          "ele": 0.0,
          "heading": 0,
          "lat": 41.9891200654099,
          "lon": -87.8696471409019,
          "satellites": 1,
          "speed": 0
        }
      ],
      "tripId": "43a8acdb-6966-4a56-b61d-a53f45d5e2e3",
      "tripMile": 0.0
    }
  ]
}

0 个答案:

没有答案