I have a simple springboot program which takes a json and prints it. The main intention was to do json validator package usage, but the current context is on the basic request parsing. The problem is when i tryy to map the input request into an class entity, it is giving the below error : "org.springframework.http.converter.HttpMessageNotReadableException",.
Controller ( Hello.java ) :
@RequestMapping(method = RequestMethod.POST , consumes = "application/json") public ResponseEntity<String> welcome( @RequestBody DemoEntity demoEntity ) { System.out.println(demoEntity.getName()); String response ="success"; return new ResponseEntity<>(response, HttpStatus.CREATED); } }Java Class entity :
public class DemoEntity implements Serializable {
@JsonProperty("name") private String name; @JsonProperty("no") private int no; public int getNo() { return no; } public void setNo(int no) { this.no = no; } public String getName() { return name; } public void setName(String name) { this.name = name; } DemoEntity(String name) { this.name = name; } }- Complete Exception :
{ "timestamp": 1497594485418, "status": 400, "error": "Bad Request", "exception": "org.springframework.http.converter.HttpMessageNotReadableException", "message": "JSON parse error: Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: java.io.PushbackInputStream@75be93a7; line: 1, column: 3]", "path": "/welcome" }
Sample input request in the body : {"name":"Roopesh", "no":123123}
-sign. Please show the exact input leading to this error.