从泽西端点获取对象列表

时间:2017-11-11 16:08:30

标签: java json dropwizard

我有一个名为operator delete[]的端点,我不想将json对象列表发送到该端点,但是当我尝试发送post请求时,我得到了一个异常:

"/locations"

这是我使用的代码:

端点:

{
  "code": 400,
  "message": "Unable to process JSON"
}

地点类:

@POST
@Timed
@Consumes("application/json")
public Response addLocations(@NotNull @Valid final Locations locations)
throws FreightosException {
  locationService.addLocations(locations);
  LOGGER.info("[createLocation] Successfully created!");
  return Response.accepted().build();
}

位置模型:

@XmlRootElement
public class Locations {
  private List < Location > locations;

  public Locations(List <Location> locationsData) {
    this.locations = locationsData;
  }

  public Locations() {
    this.locations = new ArrayList <> ();
  }

  public List <Location> getLocations() {
    return locations;
  }

  public void setLocations(List <Location> locations) {
    this.locations = locations;
  }
}

JSON示例:

public class Location {
  private String ecommerceKey;

  private Country country;

  private State state;

  private Type type;

  private String value;

  private String label;


  public Location() {}
  // Setters and getters
}

0 个答案:

没有答案