我们必须在Scala案例类中使用@JsonProperty吗?

时间:2017-03-10 19:31:45

标签: json scala json-deserialization jackson-modules

大家。

这对于为案例类的Json序列化定义@JsonProperty注释似乎是一项非常不必要的练习。例如:

submit () {
  api.login(this.cred).then((res) => {
    window.localStorage.setItem('access_token', res.data.access_token)
    this.$router.push('/projects')
  })
}

通过使用 jackson-module-parameter-names 模块,可以避免在Java中避免像这样简单的@JsonProperty注释(只是重复参数的名称) -parameters javac选项:

Why when a constructor is annotated with @JsonCreator, its arguments must be annotated with @JsonProperty?

但是,这不适用于Scala案例类。有解决方案吗?

1 个答案:

答案 0 :(得分:0)

右。事实证明,默认情况下,Lagom并不包含 jackson-module-scala