json-view

Springboot swagger with JsonView

被刻印的时光 ゝ 提交于 2021-02-04 21:15:29
问题 It's possible to integrate the swagger with @JsonView ? I have one model that I use the @JsonView to return only a few fields, but the swagger-ui shows the hole model. This is my model: public class Intimacao extends EntityBase { @Embedded @JsonView({View.Intimacao_Lista.class}) private Devedor devedor; @Embedded private Sacador sacador; @Embedded private Apresentante apresentante; @Embedded private Titulo titulo; } This is my controller: @GetMapping("/") @PreAuthorize("hasRole('ADMINISTRADOR

JSON is invalid (JSONview), but I don't see how

*爱你&永不变心* 提交于 2019-12-24 00:35:54
问题 OK, I've been going nuts with this. I'm outputting a JSON from PHP, and the JSON View extension, for both Chrome and Firefox, is claiming it's invalid. Both extensions work correctly on JSON View's example, so it seems likely that there actually is something wrong with my JSON – but I have no idea what. The Firefox version has an error message: There was an error parsing the JSON document. The document may not be well-formed. The Chrome version lacks such error messages, but still prints the

How to serialize using @Jsonview with nested objects

天大地大妈咪最大 提交于 2019-12-19 05:18:50
问题 I have a class which holds a collection of another class. class A{ @JsonView(VerboseViewA.Minimal.class) String field1; @JsonView(VerboseViewA.Complete.class) String field2; @JsonView(VerboseViewA.Complete.class) Collection<B> bEntities; } class B{ @JsonView(VerboseViewB.Minimal.class) String field2; @JsonView(VerboseViewB.Complete.class) String field3; } When i serialize Class A using VerboseViewA.Complete, i want the collection bEntities to be serialized using VerboseViewB.Minimal. Is there

In JSON views, how do I flatten an object out as a single string?

放肆的年华 提交于 2019-12-12 04:31:39
问题 In my grails 3 app (I'm using grails 3.2.4), I have an object type which I want to be serialized as a string, for any Domain object that uses it: class MyDomain1 { CustomId id } class MyDomain2 { CustomId id } I want to create a view that serializes CustomId as a string, rather than an object: //instance of MyDomain1, in JSON format: { "id": "123" } How can I do this without customizing the view for every object that uses CustomId? 回答1: Json views 1.2 supports a converter API that can do what

grails v3.3.3, json views 1.2.7 : getting stack overflow when doing a deep rendering of parent object

随声附和 提交于 2019-12-11 16:22:01
问题 getting a stack overflow when deep rendering a domain object with json views. I have created a Customer domain object and Sites domain object, where Customer hasMany sites. i have created two customers and one site in bootsrap and assigned the site to first customer. I have used gorm data service to create a customerService instance from interface. As per json views documentation (section 2.5.2) i have assured that when i use the index action on the controller that i do a join fetch for sites

How can a @JsonView working with jersey

谁说胖子不能爱 提交于 2019-12-04 08:12:54
问题 I want to return different fields with different views for one object. But it always return all the fields. I created 3 different views: public class Views { public static class PublicView { } public static class ExtendedPublicView extends PublicView { } public static class InternalView extends ExtendedPublicView { } } Then in the User.java @XmlRootElement() public class User { @JsonView(Views.PublicView.class) private String username; @JsonView(Views.PublicView.class) private String

How can a @JsonView working with jersey

喜你入骨 提交于 2019-12-02 21:30:31
I want to return different fields with different views for one object. But it always return all the fields. I created 3 different views: public class Views { public static class PublicView { } public static class ExtendedPublicView extends PublicView { } public static class InternalView extends ExtendedPublicView { } } Then in the User.java @XmlRootElement() public class User { @JsonView(Views.PublicView.class) private String username; @JsonView(Views.PublicView.class) private String employeeName; @JsonView(Views.ExtendedPublicView.class) private Date birthday; @JsonView(Views

How to override @JsonView in jersey resource methods

≡放荡痞女 提交于 2019-12-01 20:31:01
问题 I have some jersey resource methods set with @JsonView annotation in order to filter the fields returned in the response. I'd like to be able in some cases to override the JsonView set in the annotation with another one or sometimes completely disable it. (some queryParam would be used to define which view should set for rendering or if it should be disabled). Any ideas? 回答1: You can customize the Jackson object writer inside a jersey filter based on the resource method annotation using the

How to override @JsonView in jersey resource methods

╄→гoц情女王★ 提交于 2019-12-01 19:10:13
I have some jersey resource methods set with @JsonView annotation in order to filter the fields returned in the response. I'd like to be able in some cases to override the JsonView set in the annotation with another one or sometimes completely disable it. (some queryParam would be used to define which view should set for rendering or if it should be disabled). Any ideas? Alexey Gavrilov You can customize the Jackson object writer inside a jersey filter based on the resource method annotation using the Jackson 2.3 ObjectWriterModifier/ObjectReaderModifier feature . Refer to the Jersey

How to serialize using @Jsonview with nested objects

时光毁灭记忆、已成空白 提交于 2019-12-01 03:30:13
I have a class which holds a collection of another class. class A{ @JsonView(VerboseViewA.Minimal.class) String field1; @JsonView(VerboseViewA.Complete.class) String field2; @JsonView(VerboseViewA.Complete.class) Collection<B> bEntities; } class B{ @JsonView(VerboseViewB.Minimal.class) String field2; @JsonView(VerboseViewB.Complete.class) String field3; } When i serialize Class A using VerboseViewA.Complete, i want the collection bEntities to be serialized using VerboseViewB.Minimal. Is there a way to achieve it? This solves my problem. I ain't sure if there is a better way to solve this.