Skip to content

Sample code of "Jackson JSON Views support" is wrong ? [SPR-12994] #17586

@spring-projects-issues

Description

@spring-projects-issues

Kazuki Shimizu opened SPR-12994 and commented

In "Jackson JSON Views support" of "22.10.1 RestTemplate", sample code is wrong ?

  • JacksonSerializationValue -> MappingJacksonValue ?

Currently:

JacksonSerializationValue jsv = new JacksonSerializationValue(new User("eric", "7!jd#h23"),
    User.WithoutPasswordView.class);
HttpEntity<JacksonSerializationValue> entity = new HttpEntity<JacksonSerializationValue>(jsv);
String s = template.postForObject("http://example.com/user", entity, String.class);

Modification candidate :

MappingJacksonValue mjv = new MappingJacksonValue(new User("eric", "7!jd#h23"));
mjv.setSerializationView(User.WithoutPasswordView.class);
HttpEntity<MappingJacksonValue> entity = new HttpEntity<MappingJacksonValue>(mjv);
String s = template.postForObject("http://example.com/user", entity, String.class);

How do think ?


Affects: 4.1.6

Referenced from: commits 581cf3a, 2b21867

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions