Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Allow to specify a Json View to serialize a property of an object #132

Open
ccasallas opened this issue Mar 27, 2018 · 1 comment

Comments

@ccasallas
Copy link

Currently it's not possible to serialize the property of an object specifying a Json view. Please create a new @JsonUseView annotation to be able to specify a view used to serialize the property.

public class Company {
  @JsonView(View.Basic.class)
  private Long id;

  @JsonView(View.Basic.class)
  private String name;

  private String extraData;
  private String sensitiveData;
  private String privateData;
  ...
}

public class User{
  private Long id;
  private String name;

  @UseJsonView(View.Basic.class)
  private Company company;
  ...
}

Or create a new set of annotations that allow this feature. For example:

@JsonViews(views={
  @View(name="basic", fields=["id", "name"]),
  @View(name="otherView", fields=["id", "name", "extraData"]),
})
public class Company {
  private Long id;
  private String name;
  private String extraData;
  private String sensitiveData;
  private String privateData;
  ...
}

public class User{
  private Long id;
  private String name;

  @UseJsonView("basic")
  private Company company;
  ...
}
@ccasallas ccasallas changed the title FEATURE: Enable to serialize a property using Json views feature FEATURE: Allow to specify a Json View to serialize a property Mar 27, 2018
@ccasallas ccasallas changed the title FEATURE: Allow to specify a Json View to serialize a property FEATURE: Allow to specify a Json View to serialize a property of a object Mar 27, 2018
@ccasallas ccasallas changed the title FEATURE: Allow to specify a Json View to serialize a property of a object FEATURE: Allow to specify a Json View to serialize a property of an object Mar 27, 2018
@lenxeon
Copy link

lenxeon commented Feb 4, 2020

what the content about UseJsonView ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants