This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Spring - Mapping Objects

 
Greenhorn
Posts: 11
Spring AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Recently, I started a new job (4 months now) and I still have a lot to learn from Spring. One of the issues we're having is that when we bring objects from the DB and map them into (Repository -> Service -> Controller) a JSON, it brings a lot of unnecessary data - For example (small example):

We have an Employee class which has a Department object and it brings the following:

Class details:

If I want to build a "custom" mapper, which is the best practice? Or how can I implement something that allows me to create a JSON that brings me something like this:

I've been doing some research and I stumbled across the following recommendations:

Jackson JSON Views
JSON Filter and JSON Views This one taken from another forum.

Also I've been thinking about using a generic object that contains a HashMap so I can include, on the Controller, the data that I want or need for an specific screen.

I really appreciate any help - hope the question is clear enough.
 
Walter Gómez
Greenhorn
Posts: 11
Spring AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question has been posted on other forum:

http://stackoverflow.com/questions/38905760/json-object-mapping-spring-data
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!