Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Spring Boot Rest API receiving JSON

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a restful endpoint with spring boot similar to the code below.  It does a mapping to my java object MyObect and it it works fine.  I was wondering if there is a way to get the JSON that was actually received by the controller?  If I wanted to the raw JSON and just print it or save it to a JSON field, is that possible?  Thanks in advance for the help.  

 
Bartender
Posts: 1249
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's possible but quite convolute.
First, you need to add a Custom Filter:



After that, you just need to tell Spring to inject an HttpServletRequest alog with MyObject:



By the way: why just not convert your object to json via Jackson ?
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!