In a spring boot prj, I am using JSONObject to accept the incomming JSON payload from the client, but the value in userCredentials is null. How to fix this??
The incoming payload is valid JSON. I checked it.
import org.json.JSONObject;
...
...
@RequestMapping(value="/helloeverybody", method=RequestMethod.POST, consumes="application/json", produces="text/plain")
public ResponseEntity<String> post(@RequestBody JSONObject userCredentials,
HttpServletRequest hsr)
JSONObject, you better create your own object containing the payload you're expecting.JSONObjectand then deal with hashmap conversion.Mapthen, something like this will do@RequestBody Map<String, Object> payload