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

MappingJacksonJsonView: Recognize Jackson Annotations (ex @JsonSerialize) when returning objects from methods annotated with @ResponseBody [SPR-9297] #13935

Closed
spring-projects-issues opened this issue Apr 2, 2012 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 2, 2012

Andrew Muraco opened SPR-9297 and commented

Currently when using MappingJacksonJsonView and the @ResponseBody annotation, there isn't a usage-specific way to customize the generated JSON, Jackson allows Mixin and hints for the serializer that influence how Jackson will generate the output. Ideally I want to use these features of Jackson rather then have to reinvent them or do extra glue code to be able to utilize them.

public class FooBar implements Foo,Bar {
//Implements String getFoo() from interface Foo
//Implements String getBar() from interface Bar
}
@Controller
public class FooController {
	@RequestMapping("/foo")
	@ResponseBody
@JsonSerialize(as=Foo.class)
	public Foo getFooObject() {
return new FooBar();
	}
}

Ideally, I would get

{"foo":"TestFooString"}

Currently, since the MappingJacksonJsonView doesn't recongize the @JsonSerialize annotation I get

{"bar":"TestBarString","foo":"TestFooString"}

Affects: 3.1 GA

Issue Links:

2 votes, 4 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Sep 19, 2014

Brian Clozel commented

this has been superseded by #11815

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants