I can’t figure out how to handle nested JSON values in my Java classes. To make it simple as possible, I created four Java classes with every ‘nested level’. However, I’m trying to have all these values in one Java class. How can I do this? Json: Java classes: Answer You can club all the supporting classes in one class
Tag: rest
Spring MVC – Separation of logic RestController and Service
I started using Spring MVC to build my first REST API 🙂 Now I struggle a bit of where to put which logic. I read the following: @RestController: Handles requests, defines the API the user can use @Service: Contains the business logic @Repository: Abstracts away from access to DB In an easy first example, I saw the flow was like
How to create a parent child Json response in Spring Boot with a Enum using Java
I am trying to create a json response from a Spring boot application where the name of the enum will be the parent structure and below that all the child will be residing . What i have created is showing only the child hierarchy but i want the parent also .Like i want below what i am getting is Below
Which HTTP status code is correct for Subscription cancel exception?
Which HTTP status code is correct for Subscription Canceled exception? I need to throw an exception when the user tries to accesses a certain page. I checked a few statuses like Payment Required, but it’s not satisfying the requirement. Any suggestion? Answer Which HTTP status code is correct for Subscription cancel exception? HTTP status codes belong to the transfer documents
How to properly filter Spring REST data
I have a Spring Data REST service with a single @Entity and Repository. When I run $ curl localhost:8080/api I get all the data stored in my repository and it works as expected. I also have a small React front end and I display that data there. My question is: Where should I filter the data? For example maybe I
Passing List in @RequestHeader Restapi
I want to pass list of string in my controller via Request Header @RequestHeader(“list”) final List<String> listOfString. Can this be used. How can I pass list of string in header via Postman? list={item1,item2,item3}. This is not working while I want to test via Postman. Is there any way? Answer You can add the header this way In the headers tab,
In Java, how do I mask values of all the matching keys of a JSON, when the structure of JSON isn’t same?
I’m looking for a way to hide/mask the sensitive details of JSON output coming from a response, like account number. All the answers I got over the web requires me to know the JSON structure before hand. Isn’t there any way to extensively traverse each key and then replace it’s value with required masking character, without knowing the JSON structure
Restful way of sending Pre-Post or Pre-Put warning message
I am trying to convert a legacy application to Restful web-services. One of our old form displayed a warning message immediately on form load. This warning message depends on a user property. For …
How to return CREATED status (201 HTTP) in ResponseEntity
There is a Spring-MVC application. In controllers, when returning the results of methods, I return via ResponseEntity<>. On success, I return (200 statutes) the OK-method. But when creating something, I would like to return the CREATED-method (201 status). I just can’t understand what kind of URL to ask in parentheses when calling through CREATED. How can this be implemented? Now
cannot resolve this error: unable to insert NULL in (“NAWFEL”. “ORDO_DEP_UUSATEUR”. “EMPLOI”)
I’m developing a user registration form, the problem I get is that when I want to test my web service in postman it shows me the following error in my eclipse console: he tells me that I cannot insert a null value in the job “emploi” column, but I entered the value of the job column in my postman as