You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have something like jacksons @JsonView in Json-B, maybe it can be called @JsonbView. It should work like the following example:
// enums to discriminate between different json views
public enum UserSubset{
MY_SUBSET_1,
MY_SUBSET_2;
}
// the user class
public class User {
private int id;
@JsonbView("mysubset1")
private String name;
// UserSubset.MY_SUBSET_1 => UserSubset.MY_SUBSET_1.name() = "mysubset1"
@JsonbView(UserSubset.MY_SUBSET_1)
private Task task;
}
// the task class
public class Task {
private int id;
// property will be (de)serialized in mysubset1, mysubset2 and the default one
@JsonbView("mysubset1, mysubset2")
private String description;
}
The value of @JsonbView is a common (array of) String or Enum which is used as a discriminator. Using something like
jsonb.toJson(user, "mysubset");
or jsonb.toJson(user, UserSubset.MY_SUBSET_1);
will outut the json with only the properties annotated with @JsonbView("mysubset1") or @JsonbView(UserSubset.MY_SUBSET_1)
Is something like this already planned?
I think it would be an extremely useful and simple approach to declare various JSON subviews quickly, easily and cleanly.
The text was updated successfully, but these errors were encountered:
nimo23
changed the title
Feature request: @JsonbSubset
Feature request: @JsonbView
Sep 12, 2023
It would be great to have something like jacksons
@JsonView
in Json-B, maybe it can be called@JsonbView
. It should work like the following example:The value of
@JsonbView
is a common (array of)String
orEnum
which is used as a discriminator. Using something likejsonb.toJson(user, "mysubset");
or
jsonb.toJson(user, UserSubset.MY_SUBSET_1);
will outut the json with only the properties annotated with
@JsonbView("mysubset1")
or@JsonbView(UserSubset.MY_SUBSET_1)
Is something like this already planned?
I think it would be an extremely useful and simple approach to declare various JSON subviews quickly, easily and cleanly.
The text was updated successfully, but these errors were encountered: