Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
However,
expMonth
is not binding properly and throws an exception. Please suggest the way forward.
Exception Stack:
org.springframework.http.converter.HttpMessageNotReadableException:
JSON parse error: Invalid numeric value: Leading zeroes not allowed;
nested exception is com.fasterxml.jackson.core.JsonParseException:
Invalid numeric value: Leading zeroes not allowed at [Source:
(PushbackInputStream); line: 4, column: 16]
–
–
As per the exception stack, you have leading zeros and hence Jackson is thrwing the exception. You can either try something like,
"name": "XXXX",
"expMonth": 7, <--- Removing the leading zero(s).
"expYear": 21
Another way is to change it to String instead,
"name": "XXXX",
"expMonth": "07",
"expYear": 21
Code:
public Class Card {
private String name;
private String expMonth;
private Integer expYear;
You can then do something like,
Integer.parseInt(expMonth);
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.