I have a JSON that I get with ObjectNode.
However, I can not get the ID of the object "LibellePrerequis" Is the method used the right one?
if I do :
String libelleprerequis = objectNode.get("id").asText();
I have the id of the script
{
"script":{
"id":2,
"name_script":"tes",
"libellePrerequis": {"id":3, "name_libelle":"Soc contrat VAM"}
}
My controller :
@PostMapping("/create")
public ResponseEntity<Script> updateScriptLibellePrerequis(@RequestBody ObjectNode objectNode) {
String libelleprerequis = objectNode.get("libellePrerequis.id").asText();
System.out.println("Libelle Prerequis with ID = " + libelleprerequis + "...");
}
error :
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException: null