【问题标题】:REST with nested JSON带有嵌套 JSON 的 REST
【发布时间】:2014-11-06 17:22:22
【问题描述】:

我有一个 JSON 对象

{
 "firstname": "foo",
 "account":
 {
   "city": "bar"
 }
}

我想在 REST 后端序列化:

@POST
public Response create(Employee e)

类:

public class Employee {
  public String firstname; 
  private Address address;
}

public class Address {
  public String city; 
}

不幸的是,我总是收到400 状态码。但是如果我这样做了

public Response create(Object o)

一切正常。有什么想法吗?

【问题讨论】:

    标签: java json rest jax-rs resteasy


    【解决方案1】:

    您的 JSON 与您的 POJO 类型不对应(映射)。在 JSON 中,您有 account,但在您的 Java 类型中,您有 address

    【讨论】:

      猜你喜欢
      • 2019-05-07
      • 1970-01-01
      • 2014-04-26
      • 2020-07-21
      • 2022-10-12
      • 2021-04-05
      • 2021-12-11
      • 2018-04-24
      • 2017-11-23
      相关资源
      最近更新 更多