Enable Jackson to not output class name during serialization (using Spring MVC)

Is there a way to get Jackson to not put the class name in Json output? I asked a question , which led to this question, but I ask what I hope for, this is a more focused question. I use Spring MVC for this, but I'm not sure how important this is.

So instead

{"NamedSystem":{"name":"Bob Dole","id":"0198b96c-fe18-4aa6-9e61-b5f7149414c2"}} 

I want

 {"name":"Bob Dole","id":"0198b96c-fe18-4aa6-9e61-b5f7149414c2"} 

I might prefer the first, but I don’t know how to get Jackson to recognize the class name when deserializing, so if anyone knows this, it will be useful too.

+6
java jackson spring-mvc serialization annotations
source share
3 answers

I found a way to do this using Spring MVC, thanks to http://pascaldimassimo.com/2010/04/13/how-to-return-a-single-json-list-out-of-mappingjacksonjsonview/#comment-4

I really walked along this route (changing the way it was serialized by Spring) and had something similar, but not quite the same (and which does not work), but it does the trick fine.

+4
source share

Not sure what to do here, but I think it is Spring that adds this name. Jackson himself would not have acted by default. This is probably more of a SpringMVC issue.

+2
source share

I think you will have to write your own serializer that processes your data. It can help you achieve this.

+1
source share

All Articles