Skip to main content

Spring Rest web services that accepts Generic JSON instead of specific

Recently when working on restful webservices, I came across a situation where I have to receive variant JSON in my Request and have to return the variant JSON in response.

In previous projects, I was using the specific Java Objects in my request and response. 
In the current project, I had no idea how to handle the generic JSON instead of specific Java objects (jackson lib that automatically marshal/unmarshal JSON/Java Objects). 

I came across the jackson's JsonNode class. Using JsonNode, I can accept any kind of Json in my request and similarly can return generic Json in my response.

Comments