0
私はREST APIで複雑なクラスを持っている:Jackson @JsonViewを使用してプロパティをシリアル化できますか?
class Complicated {
String foo
Integer bar
Instant baz
...
// lots more
}
私も
Complicated
のコレクションが含まれている別のクラスを持っている
:
私はシリアライズclass HasComplications {
String description
List<Complicated> complications
}
私HasComplications
(Spring MVCのと)、I私は直接をシリアル化していた場合
{
description: "hello world",
complications: [ {
foo: "foo1",
bar: 42
] }
}
:のみ各Complicated
のスニペットをしたいです、私はシリアル化するためのプロパティの設定ジャクソンを伝えるために@JsonView
を使用することができます。
class Complicated {
@JsonView(Views.Snippet) String foo
@JsonView(Views.Snippet) Integer bar
Instant baz
...
// lots more
}
は、私が推移complications
プロパティに、ジャクソンはすべてのプロパティをシリアル化しComplicated
をシリアル化するとき。宣言的に "このプロパティを直列化するときにこのビューを使用する"と言う方法がありますか?
class HasComplications {
String description
@UseJsonView(Views.Snippet)
List<Complicated> complications
}
似たような機能リクエストがあったようですが、私はそれについてコメントしました。 – chrylis